Limit text inside div, using Div height

萝らか妹 提交于 2019-12-10 11:42:35

问题


I'm currently working on a website. One of the things it will do is allow the admin to post news. all my news divs are fixed in height and width.
PHP queries the database for the text and cuts it at 500 characters lenght, so the text doesn´t exit my div.
Of course this is not the best approach since if I use all caps, 500 caps characters take more space than 500 normal ones....
If I also use the /br/ tag to change lines, that is also a problem, since php ->(i think) won't count that as empty spaces...

As the title suggests... I would like to know if there is any way of limiting the ammount of text in my div by using it's height....

Thanks in advance!


回答1:


Have a look at http://www.w3schools.com/css/pr_pos_overflow.asp.




回答2:


I thinks the best way is to use css in combination with a php function that limits/cuts the string and removes any html tags and tabs.

The css: min-height: 100px;

And a php function you could use is: http://php.net/manual/en/function.strip-tags.php and http://php.net/manual/en/function.substr.php



来源:https://stackoverflow.com/questions/5331046/limit-text-inside-div-using-div-height

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