text-align:start | end | left | right | center | justify | match-parent | justify-all
默认值:start
适用于:块容器
继承性:有
动画性:否
计算值:指定值,除 match-parent 值外
媒 体:视觉
inherit表现一致,只是该值继承的start或end关键字是针对父母的direction值并计算的,计算值可以是 left 和 right 。(CSS3)justify,不同的是最后一行也会两端对齐。(CSS3)text-align的justify-all值时);text-align为justify;单行文本两端对齐示例:
我是谁
你又是谁
世界末日2012
text-align的justify属性值;text-align: justify来实现两端对齐,因为text-align: justify不会处理块级内容文本的最后一行。text-align-last: justify来实现单行文本两端对齐。遗憾的是,不少浏览器尚不支持该属性。text-align或者text-align-last来实现单行文本两端对齐。那么可以换个思路,想办法让它们变成多行文本,使用伪元素派生一行新的占位内容是个不错的选择,此时再实现两端对齐,只需要text-align就行了。但是 IE7 及以下浏览器不支持伪元素,如果要支持的话,可以直接使用text-align-last。实现及效果如下:我是谁
你又是谁
世界末日2012
.demo p {
text-align: justify;
text-align-last: justify;
}
.demo p::after {
display: inline-block;
width: 100%;
height: 0;
content: "\0020";
overflow: hidden;
}
| Values | IE | Firefox | Chrome | Safari | Opera | iOS Safari | Android Browser | Android Chrome |
|---|---|---|---|---|---|---|---|---|
| Basic Support | 8.0+ | 40.0+ | 40.0+ | 8.0+ | 40.0+ | 8.0+ | 4.4+ | 28.0+ |
| start | end | 8.0-11.0 | |||||||
| 12.0+ | ||||||||
| justify | 6.0-11.0 #1 | 40.0+ | 4.0-40.0 #1 | 8.0+ | 40.0+ | 8.0+ | 4.4-40.0 #1 | 28.0-40.0 #1 |
| 12.0+ | 41.0+ | 41.0+ | 41.0+ | |||||
| match-parent | 8.0-16.0 | 40.0+ | 40.0-64.0 | 8.0-11.0 | 40.0-50.0 | 8.0-11.3 | 4.4-62.0 | 28.0-64.0 |
| justify-all | 8.0-16.0 | 40.0-58.0 | 40.0-64.0 | 8.0-11.0 | 40.0-50.0 | 8.0-11.3 | 4.4-62.0 | 28.0-64.0 |