Optimizing text length of limited space
I am displaying text strings of varying characters and length in a div of
fixed width. I'd like to fit as much text as possible in the allotted
space. My current approach is to limit the number of text characters in
the following way
var n = //some number
string = string.substr(0,n);
The problem with this approach is that different characters have different
widths so while it can cap over spill it often leaves unused space. I've
tried giving the containing div the following css properties.
div{
width:200px
white-space:nowrap
}
But the text still wraps to the next line down once it over spills the
width. Can someone help me out with a good practice way of addressing this
problem.
No comments:
Post a Comment