Why do I have different behavior in Safari and Chrome with flexbox?
I show a series of images. Here is my html :
<div class="flex"> <img src="img1.jpg"/> <img src="img2.jpg"/> <img src="img3.jpg"/> <img src="img4.jpg"/> </div> Here is my css :
.flex { display: flex } img { height: auto; } I want my images to appear in a row. I didn’t give img any width, so Chrome Chrome takes its natural width and pops out more than the screen. This is how I want it to work. With Safari they flexbox will only handle viewport width. I tried to set the image width, flex-basis, but cannot use Safari more than just the visible screen. Is there a flexbox issue that I don't know about? What else can I do?
+5
2 answers
I think safari needs the -webkit options for it to work. eg
.flex { display: flex; display: -webkit-flex; } img { height: auto; } This is the same for all parameters. eg
justify-content: center; -webkit-justify-content: center; align-items: stretch; -webkit-align-items: stretch; This page is a good reference source for flexbox:
http://www.sketchingwithcss.com/samplechapter/cheatsheet.html
0