首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

文本对齐 | text-justify

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

代码语言:javascript
复制
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——浏览器根据性能和质量之间的平衡,选择适合当前情况的最佳类型,并且要求最适合当前文本语言(例如,英语,中日韩语言等)。如果text-justify没有设置,则这是默认的对齐方式。

inter-word——通过在单词之间添加空格(适时改变word-spacing)来使文本分布最为合适,这对于使用空格(例如英语或韩语)分隔单词的语言是最合适的。

inter-character——通过在字符之间添加空格来有效地改变文本是合理的(适时改变letter-spacing),这对日语等语言来说是最合适的。

distribute——表现与inter-word相同,该值为保持向后兼容性而保留。

形式语法

代码语言:javascript
复制
auto | inter-character | inter-word | none

实例

代码语言:javascript
复制
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

扫码关注腾讯云开发者

领取腾讯云代金券