0

Whatever I do, I can't seem to get the columns that float left and right to center and align to the middle of it's container. Is there a way with Flexbox only to just have a left and right column, but still align them in the middle? It works fine in Firefox and Chrome, but not on Safari 8.

https://jsfiddle.net/vhem8scs/68/

.container {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ccc;
  height: 200px;
  margin-top: 20px;
}

.column:after {
  content: '';
  display: table;
  clear: both;
}

.column div {
  float: left;
}
.column div:last-child {
  float: right;
}

Update

I added the following line to the container.

justify-content: space-between

While it aligns to the center/middle of the container, the floats do not work now.

Miura-shi
  • 4,409
  • 5
  • 36
  • 55

1 Answers1

1

Unfortunately it is rather difficult to visualize what you're trying to accomplish with your styles, but here's my preliminary analysis of the issue.

Once you declare an element to be a flex container, all the children will follow flexbox rules. Float styles will essentially be ignored. As a result, what you might want to try doing is making use of the flex-grow, flex-shrink, and flex-basis properties on the children to ensure columns sit in the proper position.

If you goal is to simply put space in between the columns, utilize the justify-content property with either space-around or space-between on the parent flex element.

Hope this helps!

bencodezen
  • 1,023
  • 7
  • 17
  • Thank you, I will try this. I am just trying to have two columns with one that floats to the left, and one to the right, but align them in the middle/center of the container. – Miura-shi May 11 '17 at 18:30