[英]Make the previous line of the text shorter than the next
Is there any way to make the previous line of the text always shorter than the next if the text's length is unknown? 如果文本的长度未知,是否可以使文本的前一行总是比下一行短? Somethig like this:
这样的东西:
Lorem ipsum dolor sit amet, consectetur adipiscing
et libero posuere pellentesque. Vivamus quis nulla justo.
vel lacinia sapien scelerisque eget. Vivamus ut velit elit. Donec
There is only a paragraph in HTML. HTML中只有一个段落。
I have tried to do this with text-indent or :first-line or playing around with padding and width of a paragraph but none of them is working (as expected I think...). 我试图用text-indent或:first-line或用段落的填充和段落宽度来做到这一点,但是它们都不起作用(我认为是预期的...)。 Also have tried to somehow calculate the width of line using Calculating text width but also with no result (I'm not very good in jquery...).
也尝试过使用计算文本宽度以某种方式计算行的宽度,但也没有结果(我在jquery中不是很好...)。
I can't add extra markup on the html (well, not directly, I can add it with scripts if necessary). 我无法在html上添加额外的标记(嗯,不是直接添加,如有必要,我可以使用脚本添加它)。
Preferably with css but I can add jquery too. 最好使用CSS,但我也可以添加jquery。
Please help. 请帮忙。
Yes, you can just use the selector p and attribute it to the section of there sentence where you want this paragraph to end for and use line-height to adjust its leading for instance http://jsfiddle.net/AMmYR/4/ 是的,您可以仅使用选择器p并将其归入希望该段结尾的句子部分,并使用line-height调整其开头,例如http://jsfiddle.net/AMmYR/4/
p {
font:14px nor Futura, sans-serif;
line-height:20px;
color:#333;
}
<p>This is my first sentence.
<br>This is a very, very, very, long sentence
<br>This sentence is longer than the last, I don't know why.</p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.