我正在使用Jekyll建立一个网站,我使用的是一个flexbox模型,在这个模型中,观众可以点击一个帖子,并将它带到文章页面。问题是我的网格设置为每行显示3个帖子,然后换行。默认情况下,第一个发布的文章是您看到的第一篇文章,而最新的文章最终结束,所以我试图使用flexbox来反转这一点。如何使用flexbox首先显示最近的帖子?
如果我在该网站上只有7个帖子,最后的帖子将在它自己的一行上,有两个空的空格,所以如果我使用'wrap-reverse',该帖子将是顶行,这不是我想要的。我希望我的帖子从左到右显示为[7,6,5 - 4,3,2 - 1],而不是默认的[1,2,3 - 4,5,6 - 7] ,其中7是最新的文章,1是最古老的。
我正在寻找一种可能的方法来以整洁的方式安排我的帖子,这样当我上传新帖子时,他们会自动发布在网格布局的左上角。对不起,如果这听起来令人困惑。如果您有任何问题可以帮助理解我在说什么,请随时提问。
下面是codepen的一些代码,说明了我有什么。 http://codepen.io/pen/?editors=110
<body>
<div class="container">
<div class='post'>1 (oldest post)</div>
<div class='post'>2</div>
<div class='post'>3</div>
<div class='post'>4</div>
<div class='post'>5</div>
<div class='post'>6</div>
<div class='post'>7 (newest post)</div>
</div>
</body>
.container {
display: flex;
flex-wrap: wrap;
}
.post {
height: 170px;
width: 220px;
background: black;
color: orange;
margin: 10px;
font-size: 24px;
text-align: center;
}
我基本上要7更换1次,6更换2,5更换3等 感谢您的帮助!
你的笔是空白的? – zer00ne
Flex-direction:row/column-reverse – Akxe
不幸的是,'flexbox'并没有真正提供你正在寻找的那种“magic bullet”。真正的解决方案是调整Jekyll以最近的顺序发布。 –