Making a flex item float right

You can’t use float inside flex container and the reason is that float property does not apply to flex-level boxes as you can see here Fiddle.

So if you want to position child element to right of parent element you can use margin-left: auto but now child element will also push other div to the right as you can see here Fiddle.

What you can do now is change order of elements and set order: 2 on child element so it doesn’t affect second div

.parent {
  display: flex;
.child {
  margin-left: auto;
  order: 2;
<div class="parent">
  <div class="child">Ignore parent?</div>
  <div>another child</div>

Leave a Comment