Reputation: 20997
I have a div
with an image and a label in it. The label must be ontop of the image so i made the outer container div relative
.
But i also want that the container div
has the same width as the image. So i can set a 100%
width on my label. I also don't know the width of the image before hand. This is loaded dynamically.
But the container
div always has a 100%
width set to it. Is there any way to let it have the width of the image that is inside?
Example: http://jsfiddle.net/sbNZu/391/
Upvotes: 0
Views: 53
Reputation: 207861
Do one of the following rules to your container:
display:inline-block
float:left
Either will shrink the container div to fit the contents.
Upvotes: 1