如何使用display:grid
,因此它仅定位.entry
或.post
元素并排除档案标题和分页?
(archive-description
和pagination
跨越内容div的整个宽度)
.content {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-gap: 20px;
}

<main class="content">
<div class="archive-description">Archive Title</div>
<article class="post entry">This is a post</article>
<article class="post entry">This is a post</article>
<article class="post entry">This is a post</article>
<li class="pagination">Previous & Next Entry</li>
</main>
&#13;
答案 0 :(得分:7)
您可以使用archive-description
在网格的各列跨越 pagination
和grid-column: span 3
。
请参阅下面的演示 - 添加边框以进行说明(同时将li
设置为div
以获得有效标记:
.content {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-gap: 20px;
position: relative;
border: 1px solid green;
}
.archive-description, .pagination {
grid-column: span 3;
text-align: center;
}
main > * {
border: 1px solid;
}
<main class="content">
<div class="archive-description">Archive Title</div>
<article class="post entry">This is a post</article>
<article class="post entry">This is a post</article>
<article class="post entry">This is a post</article>
<div class="pagination">Previous & Next Entry</div>
</main>