2

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 want

.description {
  max-width:590px;
  max-height:100px;
  float:left;
}

result what i got now

enter image description here

i want like this image

Community
  • 1
  • 1
mans
  • 1,087
  • 4
  • 26
  • 44

2 Answers2

5

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)

Community
  • 1
  • 1
Mr. Alien
  • 153,751
  • 34
  • 298
  • 278
  • your example its working a single line, if div width 400px; height 100px; how to fit.? – mans Nov 15 '12 at 09:23
1

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/

kongaraju
  • 9,344
  • 11
  • 55
  • 78
  • This works, but he asked for multiple lines of text in a div not a single line in a list-item – Toby Nov 15 '12 at 12:56