gpt4 book ai didi

html - flexbox 中的统一汽车元素高度

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

我有一个带有 flexbox 和多个 flex 元素的页面, flex 元素代表帖子,这些帖子有时有大标题,有时有小标题,导致每行的高度不统一,正如您在这张图片中看到的:

page

我不想设置固定高度,因为现在小标题会有很大的空白空间。相反,我希望每行的高度保持不变,并且等于可能包含帖子元素的最小高度。

这是我的CSS:

/* Post Pages */

.post-containter {
padding:4%;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
align-content: space-around;
}
.post {
text-align: center;
width: 250px;
padding: 10px 10px;
border-radius: 5px;
border: thin solid #f8f8f8;
box-shadow: 1px 1px 2px rgba(0,0,0,0.1);
background-color: white;
display: inline-block;
margin-top: 15px;
transition: box-shadow 150ms ease-in-out;
}
.post h5 {
font-weight: normal;
margin:5px;
}
.post:hover {
box-shadow: 0px 0px 25px rgba(0,0,0,0.1);
}
.posts-head {
text-align: center;
font-weight: bolder;
font-size: 50px;
}
img.post-image {
max-width: 100%;
height: auto;
border-top: 3px solid #558abb;
border-bottom: 3px solid #00c8bd;
}

这是 HTML:

<div class="post-containter">
{% for post in site.posts %}
<a href="{{post.url}}">
<div class="post">
<img class="post-image" src="{{ post.image_path }}" alt="{{ post.title }}"/>
<h5>{{ post.title }}</h5>
</div>
</a>
{% endfor %}
</div>

网站引用:https://squircleart.github.io/posts.html

最佳答案

这里的主要问题是 post 的父元素,即包装它的链接。

如果你给它 display: flex 它会工作

.post-containter > a {
display: flex;
}

关于html - flexbox 中的统一汽车元素高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44563785/

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