James Mitchell
James Mitchell

Reputation: 2467

Div Wrapped around image has border that exceed past image

I'm not sure if that title made sense but I'll try to explain to the best of my ability.

I want to add a div basically on top of an image, which is simple. I wrap the image around a div and then give things like top:, left:, from that.

Yet this div that the image is inside of exceeds the border of the actual image and goes all the way out to the parent div. How do I make it so that the border of the div just wraps around the actual image inside the div.

The black square is an image. But the div with the class of image, does not have a border that wraps around the image.

<div id="page">

    <div class="image">
        <img src="http://upload.wikimedia.org/wikipedia/commons/8/85/Black_300.jpg">
            <div class="innerimage"></div>
    </div>

</div>

Upvotes: 0

Views: 1343

Answers (1)

chrx
chrx

Reputation: 3572

Add display: inline-block to the .image div:

display: inline-block;

http://jsfiddle.net/wwRhB/4/

Upvotes: 2

Related Questions