85053

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 dotts...

i tried this, i dont see the result really what i want

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

<img src="https://i.stack.imgur.com/04MjJ.jpg" alt="result what i got now">

<img src="https://i.stack.imgur.com/8oPc1.jpg" alt="enter image description here">

i want like this image

Answer1:

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

<strong>Demo</strong>(Source)

Answer2:

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/

Recommend

  • Is it possible to run a playbook in “pull mode”?
  • Why would you want to use composition in golang?
  • Deploying a sample Spring Web MVC project
  • Render QGraphicsScene according to zoom level
  • OpenOptionsMenu not working with ActionBarSherlock Custom SubMenu
  • How to remove left and right margins from all wrapped rows in flexbox (without nth-child or js)
  • I don't get what's the difference between format() and … (python)
  • Get the last date of each month in a list of dates in Python
  • How to define an array of floats in Shader properties?
  • Scala: Function returning an unknown type
  • Can't delete or rename original file after resizing
  • RxJava debounce by arbitrary value
  • D3 get axis values on zoom event
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • C: Incompatible pointer type initializing
  • Alternative To body {overflow:scroll;} That Will Prevent Page Jostling/Wriggling?
  • Custom validator control occupying space even though display set to dynamic
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • OpenGL 3.3 on Mac OSX El Capitan with LWJGL
  • Python urlparse: small issue
  • Disable Enter in editText android
  • Change multiple background-images with jQuery
  • FileReader+canvas image loading problem
  • Linq Objects Group By & Sum
  • Optimizing database types to compact database (SQLite)
  • Opengl-es onTouchEvents problem or a draw problem? [closed]
  • How to set/get protobuf's extension field in Go?
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • How to check if every primary key value is being referenced as foreign key in another table
  • Validaiting emails with Net.Mail MailAddress
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • Change an a tag attribute in JavaScript based on screen width
  • Javascript + PHP Encryption with pidCrypt
  • How to show dropdown in excel using jrxml (jasper api)?
  • How to get next/previous record number?
  • Buffer size for converting unsigned long to string
  • python regex in pyparsing
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • python draw pie shapes with colour filled
  • reshape alternating columns in less time and using less memory