text-align:start | end | left | right | center | justify | match-parent | justify-all
默認值:start
適用于:塊容器
繼承性:有
動畫性:否
計算值:指定值,除 match-parent 值外
justify
兩端對齊生效,需要在漢字間插入有空白,如空格;justify
;css code:
li{overflow:hidden;width:200px;height:21px;text-align:justify;text-align-last:justify;} li:after{display:inline-block;overflow:hidden;width:100%;height:0;content:'';}
html code:
<ul> <li>我 是 誰</li> <li>你 又 是 誰</li> <li>世 界 末 日 2012</li> </ul>
以上代碼3個li中的內容都將兩端對齊
需注意幾點:所以就目前情況來看,使用第一種方案是比較簡約的,可以輕易的兼容IE5.5-10, Firefox, Chrome, Safari, Opera
Values | IE | Firefox | Chrome | Safari | Opera | iOS Safari | Android Browser | Android Chrome |
---|---|---|---|---|---|---|---|---|
Basic Support | 6.0+ | 2.0+ | 4.0+ | 6.0+ | 15.0+ | 6.0+ | 2.1+ | 18.0+ |
start | 6.0-11.0 | 2.0+ | 4.0+ | 6.0+ | 15.0+ | 6.0+ | 2.1+ | 18.0+ |
end | 6.0-11.0 | 2.0-3.5 | 4.0+ | 6.0+ | 15.0+ | 6.0+ | 2.1+ | 18.0+ |
3.6+ | ||||||||
justify | 6.0-11.0 #1 | 2.0+ #2 | 4.0-40.0 #1 | 6.0+ | 15.0-27.0 #1 | 6.0+ | 2.1-4.4.4 #1 | 18.0-39.0 #1 |
41.0+ | 28.0+ | 40.0+ | ||||||
match-parent | 6.0-11.0 | 2.0-37.0 | 4.0-41.0 | 6.0-8.0 | 15.0-27.0 | 6.0-8.3 | 2.1-4.4.4 | 18.0-40.0 |
justify-all | 6.0-11.0 | 2.0-37.0 | 4.0-41.0 | 6.0-8.0 | 15.0-27.0 | 6.0-8.3 | 2.1-4.4.4 | 18.0-40.0 |