📅  最后修改于: 2023-12-03 14:41:49.994000             🧑  作者: Mango
CSS3引入了多列布局属性,可以使得文本内容更好地适应各种终端设备。其中,columnGap属性用于设置列间距,即每一列之间的间隔大小。
column-gap: length | normal | initial | inherit;
设置一个三列布局,每一列宽度为200px,间距为20px。
<style>
#container {
column-count:3; /*设置列数为3*/
column-gap:20px; /*设置列间距为20px*/
width:660px;
margin:0 auto;
}
#container p {
margin:0;
padding:20px;
background-color:#eee;
}
</style>
<div id="container">
<p>1Lorem ipsum dolor sit amet, consectetur adipiscing elit,.</p>
<p>2Suspendisse ante magna, bibendum vel suscipit eu,.</p>
<p>3Phasellus at tincidunt magna, vel placerat leo.</p>
<p>4Cras cursus dignissim enim, eu consequat est facilisis at.</p>
<p>5Proin sed ante eget ipsum molestie pharetra id eget odio.</p>
<p>6In ac felis orci.</p>
<p>7Vivamus auctor ligula non augue eleifend,.</p>
<p>8Integer faucibus, mauris tempus blandit cursus,.</p>
<p>9Maecenas eu sollicitudin felis.</p>
</div>
效果如下:
1Lorem ipsum dolor sit amet, consectetur adipiscing elit,.
2Suspendisse ante magna, bibendum vel suscipit eu,.
3Phasellus at tincidunt magna, vel placerat leo.
4Cras cursus dignissim enim, eu consequat est facilisis at.
5Proin sed ante eget ipsum molestie pharetra id eget odio.
6In ac felis orci.
7Vivamus auctor ligula non augue eleifend,.
8Integer faucibus, mauris tempus blandit cursus,.
9Maecenas eu sollicitudin felis.