Skip to content Skip to sidebar Skip to footer

Fit Text Inside Div

How can i fit a large amount text a fixed size div.? i want when reach text maximum width of this div then break text with dots... i tried this, i dont see the result really what i

Solution 1:

Give it a fixed width and use text-overflow CSS property width a value ellipsis

Demo

text-overflow: ellipsis;

Note: This will be effective only for a single line

If you want this should work on a multiple line, then you need to use jQuery

Demo(Source)

Solution 2:

use text-overflow properties

text-overflow:ellipsis;

and you should keep.

overflow:hidden;
white-space:nowrap;

Here is a reference to use overflow content.

https://developer.mozilla.org/en-US/docs/CSS/text-overflow

DEMO

Here is a jquery plugin that handle multiple lines of text. One that seems to work is: http://pvdspek.github.com/jquery.autoellipsis/

An example: http://jsfiddle.net/VpmbL/

Post a Comment for "Fit Text Inside Div"