style ul with width to accommodate items
Posted
by
Tallmaris
on Stack Overflow
See other posts from Stack Overflow
or by Tallmaris
Published on 2012-10-03T09:27:43Z
Indexed on
2012/10/03
9:37 UTC
Read the original article
Hit count: 157
Sorry I could not find a similar answer on SO. I have the following markup (generated by jquery ui autocomplete but this is not the issue here)
<ul style="z-index: 1; display: block; border: thin solid red; width: 200px;">
<li>
<a>
<div style="font-size: 0.85em;">
<span style="float: right; padding-left: 10px; color: gray;">
United Kingdom
</span>
<span style="">text text text text text</span>
</div>
</a>
</li>
</ul>
As you can see in this fiddle: http://jsfiddle.net/fVr8P/2/ the text wraps because the width is limited and the country span is "floating". What I would like would be for the width to enlarge to accommodate the full length, but if I put width: auto;
it will expand to 100%.
Background
The ul is of course coming from jquery ui autocomplete. I am styling the results a bit using the autocomplete.html extension. Problem is that everything is working ok in firefox an chrome because the autocomplete is set to the correct width on creation. in IE this does not happen (width is too small) so the text wraps. I am hping to come to a simple css only solution, without fiddling around in jQuery.
© Stack Overflow or respective owner