我希望以单行(水平方式)对齐20多个图像。在Firefox和Chrome中工作的'inline-flex'属性期待safari。
<div class="rl-collection-img content" >
<div class="rl-images_container">
<img alt="" src="/staticassets/images/home/collections/blue/1.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/2.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/3.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/4.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/5.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/6.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/7.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/8.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/9.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/10.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/11.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/12.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/15.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/16.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/17.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/18.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/19.jpeg" />
<img alt="" src="/staticassets/images/home/collections/blue/20.jpeg" />
</div>
</div>
<style>
.content{
width:100%;
}
.rl-images_container{
display: inline-flex;
}
答案 0 :(得分:31)
在inline-flex上有一个特定于浏览器的扩展程序。你需要这样做:
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
答案 1 :(得分:3)
用于主容器
white-space: nowrap;
width: auto;
用于物品
display:inline-block;
答案 2 :(得分:1)
使用此代码
.content{
width:800px;
}
.rl-images_container{
width: auto;
}
.rl-images_container img{
width:30px;
float:left;
}
答案 3 :(得分:0)
并非所有浏览器都完全支持此属性。试试这个CSS以获得更多支持:
.flex-container {
display: -webkit-box; /* iOS 6-, Safari 3.1-6 */
display: -moz-box; /* Firefox 19 */
display: -ms-flexbox; /* IE 10 */
display: -webkit-flex; /* Chrome */
display: flex; /* Opera 12.1, Firefox 20+ */
}
.flex-item {
-webkit-box-flex: 1; /* iOS 6-, Safari 3.1-6 */
-moz-box-flex: 1; /* Firefox 19- */
-webkit-flex: 1; /* Chrome */
-ms-flex: 1; /* IE 10 */
flex: 1; /* Opera 12.1, Firefox 20+ */
}