简体   繁体   English

使文本的上一行比下一行短

[英]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.

相关问题 如何使顶线短于底线(在div内) - How to make top line shorter than bottom line (within div) 用 fs 读取文本文件的上一行/下一行? - Read previous/next line of text file with fs? 有一排固定宽度的图像,但是如果最后一个图像比其他图像短,则换行失败 - Have a row of fixed width images, but to next line wrap fails if last image is shorter than others 如何使文本显示在javascript类型的写作效果的下一行中 - How to make text appear in next line in javascript type writing effect 如何使用javascript在html文本框旁边创建自动行号? - How to make automatic line numbers next to an html text box with javascript? 如何使文本流向下一行,并隐藏顶部? - How to make text flow to next line up, and hide the top? 需要使文本更短(文本溢出有问题:省略号) - Need to make shorter text (Having problems with text-overflow: ellipsis) 如果文本长于容器,如何使文本分成新行 - How to make text break into new line if it's longer than container 如何使跨度填充当前行的空白空间并继续在下一行显示剩余文本 - How to make the span to fill empty space on current line and continue to show remaining text on next line 如何使图像轮播控件“下一个”和“上一个” - How to make Image Carousel Controls 'next' and 'previous'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM