text-align-last

Baseline 2022
Newly available

Since September 2022, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

CSS 属性 text-align-last 指定一行或者块中的最后一行在被强制换行之前的对齐规则。

语法

css
/* 关键字值 */
text-align-last: auto;
text-align-last: start;
text-align-last: end;
text-align-last: left;
text-align-last: right;
text-align-last: center;
text-align-last: justify;

/* 全局值 */
text-align-last: inherit;
text-align-last: initial;
text-align-last: revert;
text-align-last: revert-layer;
text-align-last: unset;
初始值auto
适用元素区块容器
是否是继承属性
计算值as specified
动画类型离散值

auto

受影响的行会根据 text-align 的值来对齐,除非 text-align 的值是 justify,在这种情况下,其效果等同于将 text-align-last 的值设置为 start

start

如果内容方向是左至右,则等于 left,反之则为 right

end

如果内容方向是左至右,则等于 right,反之则为 left

left

行内内容对齐到行框的左边缘。

行内内容对齐到行框的右边缘。

center

行内内容在行框中居中。

justify

最后一行文字的开头与内容盒子的左侧对齐,末尾与右侧对齐。

形式语法

text-align-last = 
auto |
start |
end |
left |
right |
center |
justify |
match-parent

示例

对齐最后一行

css
p {
  font-size: 1.4em;
  text-align: justify;
  text-align-last: center;
}

规范

Specification
CSS Text Module Level 3
# text-align-last-property

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
text-align-last
auto

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Requires a vendor prefix or different name for use.
Has more compatibility info.

参见