1

Basically, given a template like this:

<div class="container">
  <div class="item-one">
  </div>
  <div class="item-two">
  </div>
  <div class="item-three">
  </div>
</div>

Where class="container" is a flexbox:

.container {
  width: 1000px;
  height: 100px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
}

How would you align the three items like this:

[ item-one item-two item-three]

I can't use floats since I am using flexbox, and the reason I am using flexbox is because item-two is dynamic and may have a varying width.

Thanks

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
user1354934
  • 8,139
  • 15
  • 50
  • 80
  • If [item-two] has variable width, as you mention, that's no big deal. You can apply `justify-content: space-between` (or `space-around`) to the container. But if [item-one] and [item-three] are not equal width, you'll need another method. See boxes #71-78 here: [**Methods for Aligning Flex Items**](http://stackoverflow.com/a/33856609/3597276) – Michael Benjamin Sep 13 '16 at 22:50
  • Set the items to "flex: 1" and change the "justify-content" property on the container class to "space-between". – CoenFuze Sep 13 '16 at 22:52
  • 1
    @cewn, if you set the items to `flex: 1`, they consume all space, and `space-between` does nothing. – Michael Benjamin Sep 13 '16 at 22:53
  • Ah forgot, change flex flow to "row wrap" on the container and try "flex: 1 1 auto" on the items. – CoenFuze Sep 13 '16 at 23:16

0 Answers0