gpt4 book ai didi

html - CSS 列数 - 更改顺序

转载 作者:太空狗 更新时间:2023-10-29 15:55:18 29 4
gpt4 key购买 nike

我想在这里更改列的顺序:

#container {
position: relative;
width: 600px;
}

#column-wrapper {
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3;
-webkit-column-gap: 20px;
-moz-column-gap: 20px;
column-gap: 20px;
}

#column-wrapper .column {
display: inline-block;
width: 100%;
padding: 20px 0;
margin-bottom: 20px;
background-color: green;
text-align: center;
font-size: 20px;
font-weight: bold;
color: #fff;
}
<div id="container">

<div id="column-wrapper">

<div class="column">
<span>1</span>
</div>

<div class="column">
<span>2</span>
</div>

<div class="column">
<span>3</span>
</div>

<div class="column">
<span>4</span>
</div>

<div class="column">
<span>5</span>
</div>

<div class="column">
<span>6</span>
</div>

</div>

</div>

结果应该是这样的: Column Count

有人知道一个简单的解决方案吗?

最佳答案

当您想要基于行的顺序时为什么要使用列?看起来像是 the flex model 的工作.在不更改 HTML 的情况下,您可以这样做:

#container {
position: relative;
width: 600px;
}

#column-wrapper {
display: flex;
flex-wrap: wrap
}

#column-wrapper .column {
display: inline-block;
width: calc(30% - 20px);
padding: 20px 0;
margin: 20px;
background-color: green;
text-align: center;
font-size: 20px;
font-weight: bold;
color: #fff;
}
<div id="container">

<div id="column-wrapper">

<div class="column">
<span>1</span>
</div>

<div class="column">
<span>2</span>
</div>

<div class="column">
<span>3</span>
</div>

<div class="column">
<span>4</span>
</div>

<div class="column">
<span>5</span>
</div>

<div class="column">
<span>6</span>
</div>

</div>

</div>

关于html - CSS 列数 - 更改顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30433552/

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