1677 posts Envato Elite Author
  • Has referred 10+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
Tean says

This is my code:


<div id="circle">
   <div id="inner"></div>
</div>

#circle{
position:relative;
display:block;
width:100px;
height:100px;
background:black;

border-radius:50px;
-moz-border-radius:50px;
-webkit-border-radius:50px;

overflow:hidden;

}

#inner {
position:absolute;
width:100px;
height:30px;

background:yellow;
top:0px;
left:0px;

}

I am trying to achive the first picture, and it works in FF and IE9 , but fails in Safari, Chrome and Opera where I get second picture.

Is there a way to make this cross browser?

Thank you

47 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Made it to the Authors' Hall of Fame
  • Won a competition
+4 more
cosmocoder says

This is a known bug in Webkit, and also seems Opera is affected by it. I found this thread in Stackoverflow where it was discussed: http://stackoverflow.com/questions/6144398/rounded-corners-fail-to-cut-off-content-in-webkit-browsers-if-positionrelative

The solution is to remove the position relative declaration form the outer container. You have to position the inner element using margins then. This then works as intended in Webkit, but sadly not in Opera. Hopefully all browsers will fix this bug soon.

1677 posts Envato Elite Author
  • Has referred 10+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
Tean says

Thanks for the reply!

So in other words this cant be done?

I dont even want to ask about IE7 and 8 :D

47 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Made it to the Authors' Hall of Fame
  • Won a competition
+4 more
cosmocoder says

It seems that there is no fix for it, at least not for Opera. It will work in Firefox, IE9 and also in Webkit if you remove the position relative declaration.

IE7 and 8 does not support border radius, so no need to worry there :)

by
by
by
by
by
by