gpt4 book ai didi

html - 将网格元素跨越到 CSS 网格的整个宽度

转载 作者:技术小花猫 更新时间:2023-10-29 12:00:25 27 4
gpt4 key购买 nike

如何使用 display:grid 使其仅针对 .entry.post 元素并排除存档标题和分页?

(archive-descriptionpagination 跨越内容 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>

https://jsfiddle.net/haymanpl/rb0hqb7g/2/

最佳答案

您可以跨越 archive-descriptionpagination 使用 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>

关于html - 将网格元素跨越到 CSS 网格的整个宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46040208/

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