【发布时间】:2017-06-15 09:24:57
【问题描述】:
我有一个带有弹性框和多个弹性项目的页面,弹性项目代表帖子,这些帖子有时有大标题,有时有小标题,导致每行高度不一致,如下图所示:
我不想设置固定高度,因为现在小标题会有很大的空白空间。相反,我希望每行的高度保持不变,并且等于包含帖子元素的最小高度。
这是我的 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>
【问题讨论】:
-
你可以试试 justify-content: stretch;并处理帖子的边距。
-
我们还需要查看内部元素的 HTML 和 CSS,对于我来说
post肯定有相同的大小,但它的内容没有 -
@Gerard
justify-content没有stretch的值 -
@LGSon 我可以发布网站本身吗?squircleart.github.io/posts.html
-
可以,作为参考,虽然问题应该足以显示问题,所以它也需要更新