gpt4 book ai didi

css - 如何重复显示n个元素的网格区域

转载 作者:行者123 更新时间:2023-11-28 02:14:47 26 4
gpt4 key购买 nike

我需要重复这多行code pen issue

   <div class="list-view">
<div class="card">lorem</div>
<div class="card">ipsum</div>
<div class="card">dolor</div>
<div class="card">sit</div>
<div class="card">lorem</div>
<div class="card baner">banner</div>
</div>


.list-view {
display: grid;
border: 1px solid red;
grid-template-areas: "list advertisment";
grid-template-columns: auto 240px;
.card {
background: #ccc;
border:1px solid green;
grid-area: list;
height: 100px;
&.baner {
grid-area: advertisment;
background: yellow;
}
}
}

最佳答案

您可以将网格项分配给特定的grid-column,而不是grid-area

codepen

.list-view {
display: grid;
border: 1px solid red;
grid-template-columns: auto 240px;
}

.card {
background: #ccc;
border: 1px solid green;
height: 100px;
grid-column: 1;
}

.baner {
background: yellow;
grid-column: 2;
}
<div class="list-view">
<div class="card">lorem</div>
<div class="card">ipsum</div>
<div class="card">dolor</div>
<div class="card">sit</div>
<div class="card">lorem</div>
<div class="card baner">banner</div>
<div class="card">lorem</div>
<div class="card">ipsum</div>
<div class="card">dolor</div>
<div class="card">sit</div>
<div class="card">lorem</div>
<div class="card baner">banner</div>
<div class="card">lorem</div>
<div class="card">ipsum</div>
<div class="card">dolor</div>
<div class="card">sit</div>
<div class="card">lorem</div>
<div class="card baner">banner</div>
</div>

关于css - 如何重复显示n个元素的网格区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48540339/

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