html - 如何居中对齐 CSS 中的最后一行文本?

标签 html css

如何居中对齐文本?

目前,justify 不会将最后一行居中。

最佳答案

您可以使用 text-align-last 属性(property)

.center-justified {
    text-align: justify;
    text-align-last: center;
}

这是一个兼容性表:https://developer.mozilla.org/en-US/docs/Web/CSS/text-align-last#Browser_compatibility .

适用于所有浏览器除了 Safari(Mac 和 iOS),包括 Internet Explorer。

同样在 Internet Explorer 中,仅适用于 text-align: justify (没有其他值 text-align )和 startend不支持。

关于html - 如何居中对齐 CSS 中的最后一行文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4704896/

相关文章:

html - 使用 CSS3 变换 scale() 缩放/缩放 DOM 元素及其占用的空间

javascript - 重新加载页面后在javascript函数中通过id更改div的颜色

c# - 是否可以在表单中将 HTML 按钮设置为默认按钮?

html - 如何选择 XPath 中具有特定类的最后一个 XHTML <span> 元素?

html - Bootstrap 和绝对定位视频标签

javascript - 如何从 Jquery/JS 中的文本文件中读取数据以将其显示在 html 页面中?

php - 我正在尝试找出合适的 CSS 以使此代码适用于网站上的 Facebook 提要

Javascript 在不滚动的情况下更改 window.location.hash,但仍会触发 CSS :target pseudo-class

jquery - 调整窗口大小时,Bootstrap 搜索框不可见

css - 强制 Bootstrap 导航到纵向 ipad 上的移动 View