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

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
主站蜘蛛池模板: 浮山县| 阿尔山市| 襄垣县| 北川| 六盘水市| 汨罗市| 浙江省| 宁安市| 寻甸| 罗江县| 佛教| 汝城县| 扶绥县| 霸州市| 咸宁市| 贵州省| 武清区| 湘潭县| 纳雍县| 屯门区| 台南县| 阿合奇县| 静乐县| 明星| 宁蒗| SHOW| 青川县| 时尚| 安泽县| 栖霞市| 理塘县| 梓潼县| 安陆市| 开封市| 内江市| 长武县| 广宗县| 宝应县| 新晃| 临西县| 板桥市|