html - Restricting text in two lines using css only -
i want limit text 2 lines inside <div>
if text coming in more 2 lines, should hide rest of text after displaying 2 lines
for example:
long text continues
down road
into lane.
***this should come as:
long text continues
down road
i have using css only..
please suggest?
how fixing height of div 2 lines high, , using overflow:hidden;?
for example:
<style type="text/css"> .twolines { font-size: 20px; height: 48px; overflow: hidden; } </style> you use em values , line-height:
<style type="text/css"> .twolines { font-size: 1em; line-height: 1em; height: 2em; overflow: hidden; } </style> here's complete, working example:
<!doctype html> <html> <head> <style type="text/css"> .twolines { font-size: 1em; background-color: silver; line-height: 1em; height: 2em; overflow: hidden; } .twolines p { margin: 0; } </style> </head> <body> <div class="twolines"> <p>long text continues</p> <p>down road</p> <p>into lane.</p> </div> </body> </html>
Comments
Post a Comment