Skip to content

Instantly share code, notes, and snippets.

@beshur
Created September 25, 2012 20:35
Show Gist options
  • Save beshur/3784280 to your computer and use it in GitHub Desktop.
Save beshur/3784280 to your computer and use it in GitHub Desktop.
jQuery Opera 50% border-radius for images
<div class="content"><img src="http://placehold.it/250x250" /></div>
<style type="text/css">
img {
border-radius: 50%;
}
.o-border-radius {
display: block;
border-radius: 50%;
overflow: hidden;
}
.o-border-radius img { display: none;}
</style>
<script style="text/javascript">
$(function () {
if ($.browser.opera) {
$(".content img").each(function () {
if ( $(this).css("border-radius") == "50%" ) {
$(this).wrap('<div class="o-border-radius" style="background: url('+ $(this).attr("src") + ') 0 0 no-repeat; width: ' + $(this).width() +'px; height: ' + $(this).height() + 'px;"></div>');
}
})
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment