是否可以在第一行以一定宽度中断文本,而在第二行不中断? 例如,打断下面的文本 “Is it possible to break a text at some width for the first line and no break for the second line” 像这样第一行:-Is it possible to break a text第二行:-at some width for the first line and no break for the second line”
<div class="x"></div>
<p>Is it possible to break a text at some width for the first line and no break for the second line. Is it possible to break a text at some width for the first line and no break for the second line. Is it possible to break a text at some width for the first line and no break for the second line. Is it possible to break a text at some width for the first line and no break for the second line.</p>
2条答案
按热度按时间o8x7eapl1#
你可以在第二行空格的位置放上“非中断空格”。它会让他们在一起。
jk9hmnmh2#
您可以在文本之前添加一个不可见的(=没有内容,边框或背景)右浮动元素,使用
height: 1em
和width: calc(100% - 300px)
,您可以将px
值调整为第一个文本行的所需宽度:注意:我为浮动元素创建了一个非常浅的边框,以使其可见,但您可以简单地删除该边框设置以保持元素不可见。