1680 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.

1680 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 :)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by