I want to display a text in a small space where only two lines can fit. When the text is too long I'm looking for a way to obtain an ellipsis at the end of the second line.
I used a table but it doesn't work, I can't limit the cell height.
<td style="overflow-x: hidden;overflow-y:hidden;text-overflow: ellipsis;max-height:50px">text</td>
I've created a fiddle with a demo: http://jsfiddle.net/sandro_paganotti/N35Hw/. Unfortunately you have to know in advance if the text is going to overflow in order to display the before
selector.
<p><span>
lalla al lalla lalla la lallalla
llal alla alla alllla la la al allla
lalall alla alla alla alla alla
lla alla lalla lalla alla alla allalla lla
llala lall lalla lal
</span></p>
p{
width: 200px;
border: 5px solid black;
position: relative;
}
p:after{
content: '...';
display: block;
position: absolute;
bottom: 6px;
right: 10px;
background: #FFF;
}
span{
display: block;
margin: 10px;
height: 50px;
overflow: hidden;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With