May 26, 2011

Absolute positioned image in border radius wrapper

Question by Johan Wallberg

I have a wrapper with border radius. Inside the wrapper I have a absolute positioned image in the top right corner. My problem is that the image doesn’t crop/hide under the wrapper with border radius. I’ve tried overflow:hidden on the wrapper but it doesn’t work. See image below.

enter image description here

Answer by Starx

Image tag is not affected by border-radius.

Your best bet is to use the picture as a background like:

<div id="someimage" style="background:url('image.jpg');border-radius: 5px; height: 200px; width: 500px;"></div>

The element(in above example a div) should contain the size of the actual image), and unless you use CSS3, the image cannot be resized like <img> tag

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!