CSS多列布局實(shí)現(xiàn)方法大全
發(fā)布時(shí)間:2015-01-09 11:01:18 作者:佚名
我要評(píng)論

本文主要給大家介紹了4種使用CSS實(shí)現(xiàn)多列布局的方法,也是本人項(xiàng)目中經(jīng)常使用到的,這里推薦給大家。
摘要:
多列布局在網(wǎng)站應(yīng)用中也是經(jīng)常見到的,今天就分享4中多列布局。
display:table
復(fù)制代碼
代碼如下:<style>
.table {
width: auto;
min-width: 1000px;
margin: 0 auto;
padding: 0;
display:table;
}
.tableRow {
display: table-row;
}
.tableCell {
border: 1px solid red;
display: table-cell;
width: 33%;
}
</style>
<div class="table" >
<div class="tableRow" >
<div class="tableCell" >
one
</div>
<div class="tableCell" >
two
</div>
<div class="tableCell" >
three
</div>
</div>
</div>
float
復(fù)制代碼
代碼如下:<style>
.row {
float: left;
width: 33%;
border: 1px solid red;
}
</style>
<div class="row" >
one
</div>
<div class="row" >
two
</div>
<div class="row" >
three
</div>
display: inline-block
復(fù)制代碼
代碼如下:<style>
.row {
display: inline-block;
width: 32%;
border: 1px solid red;
}
</style>
<div class="row" >
one
</div>
<div class="row" >
two
</div>
<div class="row" >
three
</div>
column-count
復(fù)制代碼
代碼如下:<style>
.column {
/* 設(shè)置列數(shù) */
-moz-column-count:3; /* Firefox */
-webkit-column-count:3; /* Safari and Chrome */
column-count:3;
/* 設(shè)置列之間的間距 */
-moz-column-gap:40px; /* Firefox */
-webkit-column-gap:40px; /* Safari and Chrome */
column-gap:40px;
/* 設(shè)置列之間的規(guī)則 */
-moz-column-rule:4px outset #ff0000; /* Firefox */
-webkit-column-rule:4px outset #ff0000; /* Safari and Chrome */
column-rule:4px outset #ff0000;
}
</style>
<div class="column"></div>
小結(jié):
以上代碼都是在chrome上測(cè)試,如果使用請(qǐng)注意兼容性,有任何問題都可以提問
相關(guān)文章
純CSS無hacks的跨游覽器自適應(yīng)高度多列布局 推薦
翻譯自Matthew James Taylor的Equal Height Columns with Cross-Browser CSS and No Hacks,有些部分根據(jù)我的理解改了,讓一些初心者更好理解。2009-11-12- 純 CSS 打造多列等高并不像想象中那么容易。本文著重講述多列布局出現(xiàn)的問題,之后提供一個(gè)在所有瀏覽器都正常工作的簡(jiǎn)單解決方案。這個(gè)方法 100% 無 CSS hack,無圖片,無2009-08-14
CSS教程:使用ul進(jìn)行網(wǎng)頁(yè)的多列布局-CSS教程-網(wǎng)頁(yè)制作-網(wǎng)頁(yè)教學(xué)網(wǎng)
幾天在用CSS寫三列布局的時(shí)候突然想到的這樣一個(gè)方法,這個(gè)想法自己都覺得有些瘋狂,如果其中有什么不對(duì)的地方請(qǐng)各位不吝指教。 當(dāng)需要寫一個(gè)三列布局的時(shí)候,一般情況2008-10-17