How can i “limit” a text inside a <p>?

流过昼夜 提交于 2019-12-19 04:08:08

问题


i have a mail template newsletter here: http://www.newsletter.vendopor.com/m29-04-13/index2.html

But at the end, have a paragraph that contains that text: Por favor, envía este correo a las personas que creas le puede ayudar nuestro...

And this text, go out the paragraph (i have a width 380 attribute in css and keeps going out).

It's at the end of the page

I've searched in google, but can't find the solution

Works fine on Chrome, but in Mozilla (last version) the text is going out.

Thanks a lot for your help


回答1:


You can use text-overflow: ellipsis;

div {
    width:200px; 
    overflow:hidden; 
    border:1px solid #f00;
    text-overflow:ellipsis;
    white-space:nowrap; 
}
<div>This is very very long text This is very very long text This is very very long text </div>

Good Luck...




回答2:


<?php echo substr('your text',0,500); ?>

prints the first 500 characters of your text

Or when you don't want to use php and just want the text to dissapear when the end of the block is reached add overflow:hidden; in the css of the div block




回答3:


I found it, this added to the paragraph: white-space: normal; you can learn some about white-space here: sidar.org/recur/desdi/traduc/es/css/… it works good now in mozilla thx a lot to all!



来源:https://stackoverflow.com/questions/16193279/how-can-i-limit-a-text-inside-a-p

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!