官术网_书友最值得收藏!

Horizontal flex items

Flex items can be horizontal. In the following CSS, we have given the parent a fixed size, exactly three times as wide as it is high:

.flex-container-row {
display: flex;
flex-direction: row;
width: 450px;
height: 150px;
}

The following markup shows increasing numbers of flex items within the flex parent:

<div class="flex-container-row">
<!-- 1 flex item -->
<amp-img src="img/placeholder.png" layout="flex-item"></amp-img>
</div>

<div class="flex-container-row">
<!-- 2 flex items -->
<amp-img src="img/placeholder.png" layout="flex-item"></amp-img>
<amp-img src="img/placeholder.png" layout="flex-item"></amp-img>
</div>
...

<div class="flex-container-row">
<!-- 7 flex items -->
<amp-img src="img/placeholder.png" layout="flex-item"></amp-img>
<amp-img src="img/placeholder.png" layout="flex-item"></amp-img>
...
<amp-img src="img/placeholder.png" layout="flex-item"></amp-img>
</div>

The following image shows the results of having a number of flex items, ranging from one to seven, in the container. Note how the flex items are stretched depending on how many there are. The only time they aren't stretched is when there are three, because we are using square placeholder images, and the container's width is three times its height:

Horizontal flex items being stretched or squashed to fit a container. From top: 1 item, 2 items, 3 items, 5 items, 7 items
主站蜘蛛池模板: 民丰县| 广东省| 苏尼特右旗| 邹平县| 营山县| 石河子市| 桓仁| 织金县| 长白| 康乐县| 陇川县| 垫江县| 湛江市| 竹山县| 阳谷县| 尼勒克县| 景洪市| 深圳市| 九江市| 大余县| 股票| 兴化市| 西峡县| 阿拉善右旗| 成武县| 阿拉善右旗| 思茅市| 肇州县| 黄大仙区| 涡阳县| 平江县| 新巴尔虎左旗| 宾阳县| 北辰区| 大余县| 沙坪坝区| 大厂| 葫芦岛市| 涪陵区| 哈巴河县| 赣榆县|