text-align-last CSS property sets how the last line of a block or a line, right before a forced line break, is aligned.

The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.

句法

/* Keyword values */
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;
/* Global values */
text-align-last: inherit;
text-align-last: initial;
text-align-last: unset;
					

auto
The affected line is aligned per the value of text-align , unless text-align is justify , in which case the effect is the same as setting text-align-last to start .
start
如同 left if direction is left-to-right and right if direction is right-to-left.
end
如同 right if direction is left-to-right and left if direction is right-to-left.
left

The inline contents are aligned to the left edge of the line box.

right

The inline contents are aligned to the right edge of the line box.

center

The inline contents are centered within the line box.

justify

The text is justified. Text should line up their left and right edges to the left and right content edges of the paragraph.

形式定义

初始值 auto
适用于 block containers
继承 yes
计算值 如指定
动画类型 discrete

形式句法

auto | start | end | left | right | center | justify
					

范例

Justifying the last line

<p>Integer elementum massa at nulla placerat varius. Suspendisse in libero risus, in interdum massa. Vestibulum ac leo vitae metus faucibus gravida ac in neque. Nullam est eros, suscipit sed dictum quis, accumsan a ligula.</p>
					

CSS

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

Results

规范

规范 状态 注释
CSS Text Module Level 3
The definition of 'text-align-last' in that specification.
工作草案 初始定义

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
text-align-last Chrome 完整支持 47
完整支持 47
不支持 35 — 47 Disabled
Disabled ). To change preferences in Chrome, visit
Edge 完整支持 12 Firefox 完整支持 49
完整支持 49
不支持 12 — 53 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
IE 部分支持 5.5 注意事项
部分支持 5.5 注意事项
注意事项 IE only supports text-align-last when text-align is set to justify .
注意事项 start and end values are not supported.
Opera 完整支持 34
完整支持 34
不支持 23 — 34 Disabled
Disabled From version 23 until version 34 (exclusive): this feature is behind the Enable Experimental Web Platform Features preference (needs to be set to true ).
Safari 不支持 No 注意事项
不支持 No 注意事项
注意事项 See WebKit bug 76173 .
WebView Android 完整支持 47 Chrome Android 完整支持 47
完整支持 47
不支持 35 — 47 Disabled
Disabled ). To change preferences in Chrome, visit
Firefox Android 完整支持 49
完整支持 49
不支持 14 — 53 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
Opera Android 完整支持 34
完整支持 34
不支持 24 — 34 Disabled
Disabled From version 24 until version 34 (exclusive): this feature is behind the Enable Experimental Web Platform Features preference (needs to be set to true ).
Safari iOS 不支持 No 注意事项
不支持 No 注意事项
注意事项 See WebKit bug 76173 .
Samsung Internet Android 完整支持 5.0

图例

完整支持

完整支持

部分支持

部分支持

不支持

不支持

见实现注意事项。

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考
  3. CSS Text
  4. 特性
    1. hanging-punctuation
    2. hyphens
    3. letter-spacing
    4. line-break
    5. overflow-wrap
    6. paint-order
    7. tab-size
    8. text-align
    9. text-align-last
    10. text-indent
    11. text-justify
    12. text-size-adjust
    13. text-transform
    14. white-space
    15. word-break
    16. word-spacing

Copyright  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1