The other day I was trying to style CSS3 border-radius to image element and I realized that Firefox doesn't display border-radius on images. Then I figured a way to work around it — wrap a span tag around with the original image as a background-image. Thanks to Darcy Clarke for the jQuery code which does the magic tag wrapping automatically.
Goal
My goal to use the CSS3 border-radius and box-shadow feature to make the image element look like the screenshot below.

Problem
The problem is none of the modern browsers display rounded corners image the way I want it. Webkit does display the rounded corners, but the inset box shadow is not supported. In Firefox, the border-radius doesn't even display at all.
The CSS Trick
The trick is very simple: wrap a span tag around the image element. Specify the original image as background-image. To hide the original image, specify opacity:0 or display:none. I find using the opacity method is a better approach because the image will remain available for copy or download.
Final Solution With jQuery
To make things easier, we can use jQuery to automatically wrap a span tag around the image.
The jQuery code below will find any element with ".rounded-img" or "rounded-img2" (in my case, it is the image element) and wrap it with a span tag. The script finds the src, width, height, and CSS class attribute of the original image and apply them as inline styling in the span tag. Then it specifies the opacity of the image to 0 to hide it.
It works with any image dimension (with or without the width and height attribute). It can also be combined with other CSS classes. No additional markup is required.

<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".rounded-img, .rounded-img2").load(function() {
$(this).wrap(function(){
return '<span class="' + $(this).attr('class') + '" style="background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + $(this).width() + 'px; height: ' + $(this).height() + 'px;" />';
});
$(this).css("opacity","0");
});
});
</script>
Sample Usage
I hope you will find this trick useful. For example, you can use it to style your blog's avatar or profile photos.
Credits
Thanks to Darcy Clarke for the jQuery code.



Doesn’t work in my IE8…stupid IE. Works in firefox though!
I like rounded shape the most because It looks like amazing and preety good design.
When you do article marketing, your intention is to increase the number of visitors to your website. It is not our abilities that show what we truly are, it is our choices. I have look for such a article for a long time,
I experienced a little bug with this method, on the sample. I am using Firefox 3.6.12, I looked at the sample at this link:
http://www.webdesignerwall.com/demo/jquery-css3-rounded-img/
Then clicked back, back again to this article, at the end I clicked the sample link again for a closer look and then the image was not rounded, it overflown the border. After refreshing with CTRL+F5 it was working again. Just thought you might be interested. :)
Good stuff though, very good.
When you do article marketing, your intention is to increase the number of visitors to your website.ugg classic boots
Its not working in IE
It relies heavily on touch because the pages I have a user acting on, are usually a collection of child records. uggs outlet Caching is a big help in this respect.Thanks
These are awesome, and as noted before, each seem to have a distinct personality/character about them.
Thanks @darkmotion!
As you can see the iPhone 3G has a problem getting a sharp focus on objects that are close to the lens. The photo is blurry and very grainy compare with white iphone 4
This post is a solution of a very practical problem. way of expression is also impressive
If you want to follow the fashion trend, you can never miss the hottest White iphone 4 Conversion Kit. With smooth and liquidity design, we sure White iphone 4 Conversion Kit is what you want.
That is to be expected in a long-term, high-risk project like ours. So, we turned to the blogging community for help – and got it! We have published our problems, and the community responded with results!cheap ugg boots
but how-come? i think you could’f done it just with CSS
??? have you tried: “overflow: hidden” (for the borders)
nice solution,, thanks for share..
Thanks for good article kimsesiz
Thanks for sharing. Lol
nice to see this
nice to see this- csssplash.com
Thank you for your solution.
Where in my wordpress files should I place something like this? The style.css? Index.php?