开发者

How to ensure that a line of text of a certain width never wraps?

开发者 https://www.devze.com 2023-02-05 16:25 出处:网络
I have some divs with ul > li lists in them. Each item should be one line tall and should not wrap. Ideally, ellipses ... should be inserted for lines that would otherwise wrap: these li items shou

I have some divs with ul > li lists in them. Each item should be one line tall and should not wrap. Ideally, ellipses ... should be inserted for lines that would otherwise wrap: these li items should be prevented from wra开发者_C百科pping.

Is it possible to accomplish this with through a combination of css and jQuery?


Add text-overflow: ellipsis.

Unfortunately, it's not supported by Firefox.


Check out this solution using jQuery to decrement the length of the string until it fits inside the desired dimension. http://jsfiddle.net/3jwLU/


You can use CSS3 text-overflow property.

If that's not an option you have a lot of jQuery plugins that do what you want. Just search for ellipses in jQuery plugins page...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号