Reputation: 3331
A colleague of mine was working on a CSS design which contains an un-ordered list (<ul>
tag) that has its <li
> tags floated to right.
Each list item contains a <div>
(non-floating) which contains an image and a paragraph.
The inner <div>
's width is being changed when hovering above it (using a jQuery animation effect).
The problem is that when the <div>
's width is changed, it goes outside of the <li>
bounds.
Generally speaking, is there a way to expand or shrink a floating element based on its content elements' maximum width?
Upvotes: 1
Views: 692
Reputation: 26753
Just don't set any width on the LI or the UL and it will expand. Floated elements automatically "shrink-wrap" around their content - unless so specifically request otherwise by setting a height or width.
Upvotes: 4