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

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
主站蜘蛛池模板: 新河县| 平阳县| 新田县| 社旗县| 汪清县| 乌鲁木齐市| 苗栗市| 菏泽市| 临猗县| 虞城县| 瑞丽市| 鹿泉市| 淄博市| 阿拉善盟| 伊宁市| 阜南县| 汽车| 海城市| 阿克| 沂南县| 富源县| 三穗县| 正镶白旗| 大庆市| 孟津县| 龙州县| 永川市| 华蓥市| 内江市| 崇阳县| 漳浦县| 阿合奇县| 中江县| 金秀| 保山市| 霍山县| 盐池县| 青岛市| 长寿区| 涿鹿县| 隆昌县|