5

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

.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>

4

2 回答 2

6

您可以使用text-align-last

text-align-last CSS 属性描述了一个块或一行的最后一行,在强制换行之前,是如何对齐的。

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>

于 2018-09-10T15:21:41.090 回答
0

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

.paragraph {
  text-align: left;
  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>

于 2020-10-28T08:00:20.157 回答