Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrap text in list items/buttons instead of hiding the overflow

I'm trying to override the default behavior of list items and buttons in jQuery Mobile, which has text which doesn't fit on one line as hidden overflow.

If you view this on a skinny browser window or iPhone you'll see what I mean: http://m.gizmag.com

I'd like to be able to wrap the text in the h3 and p tags of each list item onto new lines.

Thanks in advance!

like image 350
Tim Avatar asked Dec 01 '10 04:12

Tim


People also ask

How do I make text not wrap the button?

If you want to prevent the text from wrapping, you can apply white-space: nowrap; Notice in HTML code example at the top of this article, there are actually two line breaks, one before the line of text and one after, which allow the text to be on its own line (in the code).

How do you force text wrap in CSS?

You can force long (unbroken) text to wrap in a new line by specifying break-word with the word-wrap property. For example, you can use it to prevent text extending out the box and breaking the layout. This commonly happens when you have a long URL in the sidebar or comment list.


2 Answers

Try setting a style of white-space:normal for the elements.

I just did this with an anchor (<a>) element inside a jQuery Mobile listview-styled li, and it worked to wrap the text as I expected. I used Chrome's developer tools to determine where the CSS attributes were coming from and interactively changed them to make it work the way I wanted.

-- Derek

like image 97
Derek Kalweit Avatar answered Oct 22 '22 09:10

Derek Kalweit


If feasible, enclosing it inside a <div> will also make it wrap. (But finding the affected element and declaring white-space:normal is the more proper solution)

Source: http://forum.jquery.com/topic/list-items-are-truncating-text-is-there-a-way-around-this

like image 37
enkash Avatar answered Oct 22 '22 10:10

enkash