I need to limit some text so that it never exceeds 2 lines
This is what I have so far:
<h3>Here is some long text, it just keeps on going and going and going.. Hello, how are you? I'm fine thank you. And yadda yadda yadda</h3>
h3 {
width: 400px;
font-size: 1.5em;
max-height: 2.4em;
line-height: 1.2em;
overflow-y: hidden;
/* perhaps throw in some padding and margin control to be sure */
}
See the script: http://jsfiddle.net/e5EKY/
This seems to work, and I tested it in several browsers with a good result.
But can I count on this? Are there any scenarios in which it will exceed 2 lines?
If the user has increased or increased the font size in the browser, the maximum height and line height should match (em), so I don't see a problem in this
(PS: I need to use em, so pixel size is not an option)
source
share