0

How do you center the second div inside a flex box if the divs around it have different width?

http://jsfiddle.net/hbtkvg2w/3/

This is my html

<div id="container">
  <div class="first"></div>
  <div class="middle"></div>
  <div></div>
</div>

This is my css:

#container {
  display: flex;
  justify-content: space-between;
  background-color: lightyellow;
}

#container > div {
  width: 100px;
  height: 100px;
  border: 2px dashed red;
}

#container > div.first {
  width: 300px;
}

I have a situation where I have a flexbox and the divs inside of it don't have the same width. So I am wondering how to ignore the width of the two divs and place the middle div right in the middle. Is this possible?

Sayaman
  • 1,145
  • 4
  • 14
  • 35

0 Answers0