CSS

文本对齐 | text-justify

text-justify

text-justifyCSS属性定义当文本设定为justified时,应该应用什么类型的对齐方式(即,有如下设定:text-align: justify;时)。

text-justify: none; text-justify: auto; text-justify: inter-word; text-justify: inter-character; text-justify: distribute; /* Deprecated value */

Initial valueauto
Applies toinline-level and table-cell elements
Inheritedyes
Mediavisual
Computed valueas specified
Animation typediscrete
Canonical orderthe 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; }

规范

SpecificationStatusComment
CSS Text Module Level 3The definition of 'text-justify' in that specification.Working Draft

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic supportNo support214155.0 (55.0)111No support2No support

FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic supportNo support2No support214155.0 (55.0)111No support2No support