CSS - text overflow: display only 2 lines of text
Given the long line of content, I only want to display the first 2 lines of text. The container for this content is fluid and will resize to the width of the browser. Regardless of the width of the container, I want the text to always show only two lines. Is there a way to do this?
If there is no way to do this, is there a way to limit based on the number of characters?
+3
source to share
4 answers
I have an idea for a workaround to solve your problem (couse, I think this is not possible for css).
So my solution works like this:
var height = parseInt($("#foo").css("line-height"));
var lineCount = 2;
height *= lineCount;
$("#foo").css("height", height + "px");
You take line-height
your container and place the height
container in line-height * lineCount
.
+1
source to share