html - 分词后,下一行向左对齐而不是居中

标签 html css word-wrap word-break text-styling

我正在设计段落样式,并且在一定数量的字符后有换行符。我希望能够使中断后的行左对齐而不是居中。

.justify {
  text-align: justify;
  text-justify: inter-word;
}

.paragraph {
  text-align: center;
  max-width: 220px;
  word-wrap: break-word;
  word-break: break-all;
}
<div class='justify'>
  <p class="paragraph">Hello, my name is Taylor and welcome to my personal website!</p>
</div>

最佳答案

你可以使用text-align-last

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

MDN

.justify {
  text-align: justify;
  text-justify: inter-word;
}

.paragraph {
  text-align: center;
  max-width: 220px;
  word-wrap: break-word;
  word-break: break-all;
  text-align-last: left;
  border: 1px solid red;
}
<div class='justify'>
  <p class="paragraph">Hello, my name is Taylor and welcome to my personal website!</p>
</div>

关于html - 分词后,下一行向左对齐而不是居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52260553/

相关文章:

css - 缩小窗口大小时出现空格?

CSS:这个插件中的汉堡包图标是如何生成的?

html - Ionic 2 文本不在选择组件中换行

sql-server - SSRS 2008 自动换行问题

c# - 多行文本作为 Windows 窗体中的按钮标签

javascript - 使用 javascript 绘制页眉/页脚包括和 document.write

html - 在 CSS 下拉菜单中单击后,从链接中删除焦点

html - 如何始终在底部做我的按钮 div?

javascript - 如何用两个图像保存 Canvas

jquery - 使用 CSS 反转动画