要实现css两端对齐,我在网上找了很多方法,都不怎么实用,都是兼容性闹得,column是css3的属性,是多列布局,使用column来实现两端对齐简单实用,就要设置下模块的个数跟column的列数一致就行,先看它的的3个属性:

1.column-count  属性规定元素应该被分隔的列数

2.column-gap  属性规定列之间的间隔

2.column-rule  属性设置列之间的宽度、样式和颜色规则。

CSS3 多列属性的兼容性:Internet Explorer 10 和 Opera 支持多列属性,Firefox 需要前缀 -moz-,Chrome 和 Safari 需要前缀 -webkit-,特别注意:Internet Explorer 9 以及更早的版本不支持多列属性。

实现css两端对齐的例子:用column-count定义对象的列数,例子中有4个p(即4个模块),那么就定义为4列,再用column-gap定义了对象中列与列的间距,间距不能设置为百分比,但是只能用px,具体的看下面的代码:

<!Doctype html><html><head>    <meta http-equiv=”Content-Type” content=”text/html; charset=gbk2312″/>    <title>实现css两端对齐</title>    <style type=”text/css”>        *{margin:0;padding:0;}        .box{            margin:100px 0;            -webkit-column-count:4;-moz-column-count:4;column-count:4;            -webkit-column-gap:30px;-moz-column-gap:30px;column-gap:30px;        }        .box p{            height:30px;            line-height:30px;            text-align:center;            border:1px solid red;            color:#000;            font-size:12px;        }    </style></head><body><div class=”box”>    <p>第1列</p>    <p>第2列</p>    <p>第3列</p>    <p>第4列</p></div></body></html>

点击查看:css两端对齐效果

原文地址:http://tangjiusheng.com/css3/130.html

极速赛车五码稳赢技巧itle>    <style type=”text/css”>        *{margin:0;padding:0;}        .box{            margin:100px 0;            -webkit-column-count:4;-moz-column-count:4;column-count:4;            -webkit-column-gap:30px;-moz-column-gap:30px;column-gap:30px;        }        .box p{            height:30px;            line-height:30px;            text-align:center;            border:1px solid red;            color:#000;            font-size:12px;        }    </style></head><body><div class=”box”>    <p>第1列</p>    <p>第2列</p>    <p>第3列</p>    <p>第4列</p></div></body></html>

点击查看:css两端对齐效果

原文地址:http://tangjiusheng.com/css3/130.html