gpt4 book ai didi

css - 简单的 css3 flex 布局垂直 - 不交叉

转载 作者:太空宇宙 更新时间:2023-11-04 10:36:23 25 4
gpt4 key购买 nike

我在使我的 CSS Flexbox 布局正常工作时遇到问题。我希望在 1170px 上得到 4 个框,但我得到的是垂直布局。我一直在 IE11 maxathon 和 chrome 中测试

这是html

.textwidget {
width: 100%;
background-color: orange;
}
.ec-postcards {
width: 1170px;
margin: 0 auto;
display: flex;
flex-flow: row nowrap;
justify-content: space-around;
}
.postcard-block {
width: 20%;
background: pink;
}
<aside class="home-postcards">
<div class="ec-postcards">
<div class="textwidget">
<div class="postcard-block ">
<img src="wp-content/uploads/2016/03/alcove-units.jpg" alt="" />
<p><a href="living">living</a>
</p>
</div>
<div class="postcard-block ">
<img src="wp-content/uploads/2016/03/alcove-units.jpg" alt="" />
<p><a href="living">living</a>
</p>
</div>
<div class="postcard-block ">
<img src="wp-content/uploads/2016/03/alcove-units.jpg" alt="" />
<p><a href="living">living</a>
</p>
</div>
<div class="postcard-block ">
<img src="wp-content/uploads/2016/03/alcove-units.jpg" alt="" />
<p><a href="living">living</a>
</p>
</div>
</div>
<!-- ec-postcards-->
</div>
</aside>

最佳答案

您将 flex 设置为错误的元素。应该把它放在你试图彼此相邻设置的元素的直接父级上。 textwidget 是明信片 block 的父级,因此应该将其设置为 flex。

.textwidget {
width: 100%;
background-color: orange;
display: flex;
flex-flow: row nowrap;
justify-content: space-around;
}
.ec-postcards {
width: 1170px;
margin: 0 auto;
}
.postcard-block {
width: 20%;
background: pink;
}
<aside class="home-postcards">
<div class="ec-postcards">
<div class="textwidget">
<div class="postcard-block ">
<img src="wp-content/uploads/2016/03/alcove-units.jpg" alt="" />
<p><a href="living">living</a>
</p>
</div>
<div class="postcard-block ">
<img src="wp-content/uploads/2016/03/alcove-units.jpg" alt="" />
<p><a href="living">living</a>
</p>
</div>
<div class="postcard-block ">
<img src="wp-content/uploads/2016/03/alcove-units.jpg" alt="" />
<p><a href="living">living</a>
</p>
</div>
<div class="postcard-block ">
<img src="wp-content/uploads/2016/03/alcove-units.jpg" alt="" />
<p><a href="living">living</a>
</p>
</div>
</div>
<!-- ec-postcards-->
</div>
</aside>

关于css - 简单的 css3 flex 布局垂直 - 不交叉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36118110/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com