我有一些卡片的HTML / CSS代碼,事情是,我需要他們每兩個“文章”區(qū)域開始一個新行。 如何才能實現(xiàn)這一點?
.tiles_bodyLOB {
display: flex;
grid-template-columns: auto auto;
column-gap: 1rem;
row-gap: 1rem;
margin-top: 0.25rem;
@media (max-width: 700px) {
grid-template-columns: repeat(1, 1fr);
}
padding: 1rem;
border-radius: 8px;
justify-content: space-between;
}
.tilesLOB {
display: grid;
grid-template-columns: auto auto;
gap: 1rem;
@media (max-width: 700px) {
grid-template-columns: repeat(1, 1fr);
}
}
.tile-styleLOB {
background-color: red;
min-height: 200px;
transition: 0.25s ease;
&:hover {
transform: translateY(-5px);
}
&:focus-within {
box-shadow: 0 0 0 2px var(--c-gray-800), 0 0 0 4px var(--c-olive-500);
}
min-width: 600px;
}
.a-tag:link {
color: white;
}
.a-tag:hover {
color: white;
}
.a-tag:visited {
color: white;
}
<div id="tile-container">
<div class="tiles_bodyLOB">
<article class="tile-styleLOB">
<h1 style="color: white; font-size: 38px;">
<span> Some Text ABC</span>
</h1>
<span style="color: white; font-size: 24px">
Sub Text 1
</span>
<a href="#">
<div style="color: white; font-size: 18px; grid-template-columns: 1fr 1fr 1fr">
<span> Case A: 1
00</span>
</div>
</a>
</article>
<article class="tile-styleLOB">
<h1 style="color: white; font-size: 38px;">
<span> Some Text ABC</span>
</h1>
<span style="color: white; font-size: 24px">
Sub Text 1
</span>
<a href="#">
<div style="color: white; font-size: 18px; grid-template-columns: 1fr 1fr 1fr">
<span> Case A: 1
00</span>
</div>
</a>
</article>
<article class="tile-styleLOB">
<h1 style="color: white; font-size: 38px;">
<span> Some Text ABC</span>
</h1>
<span style="color: white; font-size: 24px">
Sub Text 1
</span>
<a href="#">
<div style="color: white; font-size: 18px; grid-template-columns: 1fr 1fr 1fr">
<span> Case A: 1
00</span>
</div>
</a>
</article>
如果您想根據(jù)屏幕寬度來包裝文章,請?zhí)砑觙lex-wrap:wrap;敬。CSS中的tiles_bodyLOB,像這樣
.tiles_bodyLOB {
display: flex;
grid-template-columns: auto auto;
column-gap: 1rem;
row-gap: 1rem;
margin-top: 0.25rem;
@media (max-width: 700px) {
grid-template-columns: repeat(1, 1fr);
}
padding: 1rem;
border-radius: 8px;
justify-content: space-between;
flex-wrap: wrap;
}
.tilesLOB {
display: grid;
grid-template-columns: auto auto;
gap: 1rem;
@media (max-width: 700px) {
grid-template-columns: repeat(1, 1fr);
}
}
.tile-styleLOB {
background-color: red;
min-height: 200px;
transition: 0.25s ease;
&:hover {
transform: translateY(-5px);
}
&:focus-within {
box-shadow: 0 0 0 2px var(--c-gray-800), 0 0 0 4px var(--c-olive-500);
}
min-width: 600px;
}
.a-tag:link {color: white;}
.a-tag:hover {color: white;}
.a-tag:visited {color: white;}
<div id="tile-container">
<div class="tiles_bodyLOB">
<article class="tile-styleLOB">
<h1 style="color: white; font-size: 38px;">
<span> Some Text ABC</span>
</h1>
<span style="color: white; font-size: 24px">
Sub Text 1
</span>
<a href="#">
<div style="color: white; font-size: 18px; grid-template-columns: 1fr 1fr 1fr">
<span> Case A: 1
00</span>
</div>
</a>
</article>
<article class="tile-styleLOB">
<h1 style="color: white; font-size: 38px;">
<span> Some Text ABC</span>
</h1>
<span style="color: white; font-size: 24px">
Sub Text 1
</span>
<a href="#">
<div style="color: white; font-size: 18px; grid-template-columns: 1fr 1fr 1fr">
<span> Case A: 1
00</span>
</div>
</a>
</article>
<article class="tile-styleLOB">
<h1 style="color: white; font-size: 38px;">
<span> Some Text ABC</span>
</h1>
<span style="color: white; font-size: 24px">
Sub Text 1
</span>
<a href="#">
<div style="color: white; font-size: 18px; grid-template-columns: 1fr 1fr 1fr">
<span> Case A: 1
00</span>
</div>
</a>
</article>
</div>
</div>