文本对齐 | text-justify
text-justify
该text-justify
CSS属性定义当文本设定为justified时,应该应用什么类型的对齐方式(即,有如下设定:text-align: justify;
时)。
text-justify: none;
text-justify: auto;
text-justify: inter-word;
text-justify: inter-character;
text-justify: distribute; /* Deprecated value */
Initial value | auto |
---|---|
Applies to | inline-level and table-cell elements |
Inherited | yes |
Media | visual |
Computed value | as specified |
Animation type | discrete |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
语法
该text-justify
属性被指定为下面的列表中的任意一个关键字。
可能的值
none
——文本对齐关闭。这与完全没有设置text-align
的效果相同,但是如果由于某种原因需要打开和关闭对齐功能时,该设定就很有用了。
形式语法
auto | inter-character | inter-word | none
实例
p {
font-size: 1.5em;
border: 1px solid black;
padding: 10px;
width: 95%;
margin: 10px auto;
text-align: justify;
}
.none {
text-justify: none;
}
.auto {
text-justify: auto;
}
.dist {
text-justify: distribute;
}
.word {
text-justify: inter-word;
}
.char {
text-justify: inter-character;
}
规范
Specification | Status | Comment |
---|---|---|
CSS Text Module Level 3The definition of 'text-justify' in that specification. | Working Draft | |
浏览器兼容性
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | No support2 | 141 | 55.0 (55.0) | 111 | No support2 | No support |
Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | No support2 | No support2 | 141 | 55.0 (55.0) | 111 | No support2 | No support |