# Why is this flex centering not working?

**URL:** https://forum.kirupa.com/t/why-is-this-flex-centering-not-working/679790
**Category:** web dev
**Created:** [April 1, 2026, 4:00am UTC](https://forum.kirupa.com/t/why-is-this-flex-centering-not-working/679790 "2026-04-01T04:00:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ellen1979](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ellen1979/32/31260_2.png) [@Ellen1979](https://forum.kirupa.com/u/Ellen1979)
#### Post date: [April 1, 2026, 4:00am UTC](https://forum.kirupa.com/t/why-is-this-flex-centering-not-working/679790/1 "2026-04-01T04:00:06Z")

</div>

Consider this snippet.

```css
.parent {
  display: flex;
  justify-content: center;
  align-items: center;
}
.child {
  margin-left: auto;
}

```

Why does the child not stay centered, and what is the simplest fix.

Ellen 😎

---

<div class="post-metadata">

### Author: ![ArthurDent](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/arthurdent/32/31262_2.png) [@ArthurDent](https://forum.kirupa.com/u/ArthurDent)
#### Post date: [April 1, 2026, 4:14am UTC](https://forum.kirupa.com/t/why-is-this-flex-centering-not-working/679790/2 "2026-04-01T04:14:06Z")

</div>

`margin-left: auto` wins by eating the free space, so it pushes the child away from the flex centering.

Arthur
