user947462
user947462

Reputation: 949

image only showing inside of the div

I have a div that has inside an image. However if the image is bigger than div, it will fill outside of the div. What i want is a mask basically.

So the image should be visible inside the limits of the div. background-image is not an option. How can be solved?

<div style="height:400px; width:400px; background-color:red">
    <img src="xxx.jpeg"/>
</div>

http://jsfiddle.net/pJC5e/

Upvotes: 0

Views: 61

Answers (2)

Liam
Liam

Reputation: 166

Try giving the parent container a overflow: hidden rule. This will cut off the image inside when it reaches the parent's boundaries.

Upvotes: 1

adeneo
adeneo

Reputation: 318182

Using overflow: hidden I guess ?

<div style="height:400px; width:400px; background-color:red; overflow: hidden">
    <img src="xxx.jpeg"/>
</div>

FIDDLE

Upvotes: 5

Related Questions