border-radius and overflow problem


This is my code:

#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


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:

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.


Thanks for the reply!

So in other words this cant be done?

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


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 :slight_smile: