'Display div content fit to div in server side
I got a news display section in my web application. I need to show the first 2 lines of news in a div, which is 450px X 30 px height, 15 px line height.
I only need to show the first 2 lines. I did with server side string split like:
$news=$row['news'];
if(strlen($news)>200)
$news=substr($news,0,197).'...';
Its showing "sdasd asdasd ad..." if my news contains more than 200 chars ..
But the real problem is ..
Suppose my news contains more "W's " then the news will go beyond the div and show "WWWW..."
And if the news contains "i" ... Then the 2 lines will not fill even my news contains more than 500 chars ...
I would likes to fill my 2 lines with the text and append a "..." if text contains more chars.
It making my application weird look.
I have no idea how to solve this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
