HTML Remix - Dont copy code, remix it!

September 24, 2008

Curved corner (border-radius) cross browser

Posted by : Remiz
Filed under : CSS

Update 18 November , 2009: The htc file is updated by Nick F. Thanks man, you got time to check it out. Now supports FF, Chrome, Safari, IE6, IE7, IE8 (Os doesn’t matter).
This version of htc files can be found here and demo here


Update 17 August, 2009: This project is moved to Google Code. Please find the htc files on http://code.google.com/p/curved-corner. Links to htc file below will not work.


Update 16 July, 2009: htc file updated with support for IE8. Thanks to Kevin for coming up with a work-around. New htc file can be downloaded on border radius ie8.


Update 10 June, 2009: Some servers need to set MIME type for HTC to work this in IE6.
To do this, follow the steps.

1. Go to your cpanel and click the MIME Types link
2. Under MIME Type, add text/x-component
3. Under Extensions, add htc
4. Restart Apache Web server


As I’ve pledged, today I’m posting the Curved corner without any js stuff.

For firefox, you can set border-radius by prefixing “-moz” to the css property. And ofcource for webkit use “-webkit” . Now IE ?? .. As IE is not a good browser to work with css, we need to make it so. Here, you need to use a nice css hack. Some how I managed to have an htc file to make border-radius work in IE  :) . You can download it here. border-radius.htc .

The Demo

1 . I’ve just made: http://www.htmlremix.com/files/20080924-border-radius.zip

The CSS:

  1. .curved {
  2. -moz-border-radius:10px;
  3. -webkit-border-radius:10px;
  4. behavior:url(border-radius.htc);
  5. }

The HTML:

<div class="curved">Curvd div</div>

The explanation :

Do you really want an explanation for this simple 3 line css ?. I don’t think so. Ofcourse if you need, I can.

Browsers :

All browsers :)

  • Delicious 0
  • Comments (410)

410 Responses to “Curved corner (border-radius) cross browser”

  1. Greg says:

    So this works wonderfully! One question – could you also include support for border-(top/bottom)-(right/left)-radius values in there? They don’t seem to work independently.

  2. Carlos Mansilla says:

    it doesn’t work for me.. i try in IE7, but nothing.. i trying in all the web exampless across the web.. used in my own server properly configured with mime types, checked the correct URL and doesn’t work.. any tip??

  3. belle says:

    It doesn’t seem to work with background image attached to the element?

  4. This is awesome, but I dont know it’s not working for me in IE8. Are known some issues? Thanks.

  5. Rob Cozzens says:

    Amazing! Thank you!

  6. FiredMint says:

    Hard to make it work !!!

    If you have a float bloc, you can’t use this behavior. So make a absolute positioned div and put your floats into. this is a ie bug !

    http://ltslashgt.com/2007/05/16/relative-zindex-and-ie/#comments

  7. erwin says:

    Hi,

    I also tried this, but it doesn’t work for me.
    If you check my site, you wil see that IE doesn’t show my rounded corners right.
    I now removed the htc file, and let IE be with no rounded corners. But I want IE to show them.

    I think it doesn’t work if you put a div with rounded corners inside an other div?
    Cause thats wat I have done.

    anyone who knows what to do?

  8. Zachary Parm says:

    I like the layout of your blog and I’m going to do the same thing for mine. Do you have any tips? Please PM ME on yahoo @ AmandaLovesYou702

  9. alif says:

    It does works on chrome, and firefox. But not on my IE8.

  10. JET says:

    any chance this could be adapted to handle the following?

    .sweep_fromLeftUp {
    top: 185px;
    left: 232px;
    height: 15px;
    width: 15px;
    background: transparent;
    border-top: 0px;
    border-right: solid 120px lightblue;
    border-bottom: solid 30px lightblue;
    border-left: 0px;
    border-top-left-radius: 0px;
    -moz-border-radius-topleft: 0px;
    -webkit-border-top-left-radius: 0px;
    border-top-right-radius: 0px;
    -moz-border-radius-topright: 0px;
    -webkit-border-top-right-radius: 0px;
    border-bottom-right-radius: 200px 60px;
    -moz-border-radius-bottomright: 200px 60px;
    -webkit-border-bottom-left-radius: 200px 60px;
    border-bottom-left-radius: 0px;
    -moz-border-radius-bottomleft: 0px;
    -webkit-border-bottom-right-radius: 0px;
    behavior: url(/css/border-radius.htc);
    }

  11. espidesigns says:

    hi thanks for the tip. but can i get this to work along with css gradients? in testing with ie on a button, with ie’s gradient code, it looked like the rounded button is underneath the rectangular gradient…how can i get the htc command to get the gradient properties and redraw them within the rounded button? thanks!

  12. Stew says:

    Sorry, if I’m being daft, but I’m using Drupal and am trying to figure out where to put the htc file in my site/root or theme’s folder?

  13. SeRiaL- says:

    Hi,

    What about the “security protect” is IE? It is really disturbing.
    Can it be avoided?

    Thanks

    Ciao

  14. Nathaniel says:

    Hey can someone put together a complete cross-browser example of rounded corners and shadow. Also I don’t see how using the htc file gives any control over corner radius.

    Please help. Thanks!

  15. I tested this hack in FORM and it work well but don´t work in DIV´s menus
    I’ll continue testing

  16. ultradude25 says:

    It doesn’t work. MIME type is set, and it’s obviously loading because in IE, instead of showing square boxes it removes them when the page finishes loading. Doesn’t effect Firefox, it still shows the sexy rounded borders.

    .mozborder {
    border: 1px solid ThreeDShadow;
    -moz-border-radius: 10px;
    -webkit-border-radius: 10px;
    padding: 3em;
    min-width: 1em;
    max-width: 20em;
    margin: 4em auto;
    background-color: #FFFFFF;
    behavior:url(/resources/css/border-radius.htc)
    }

  17. Mike says:

    Any working fix around for opera? :s

  18. Tom says:

    A great addition to this would be to support the individual corner syntax, so you could curve a box just on the top or bottom.

    -moz-border-radius: 0px 0px 10px 10px; /* curved on the bottom */
    -moz-border-radius-bottomright: 10px; /* on the bottom right */

    That would rock!

  19. ken says:

    thanks for the tip buddy. really helps :)

  20. Stefh says:

    Hi richT, Thanks for this information! but it’s not well working for me.
    the curved corner disapear with this add… I can’t see the curved corner and shadow at the same time.

    .htc ( line 92 ):

    rect.style.filter = ‘progid:DXImageTransform.Microsoft.Shadow(color=#999999,direction=120,strength=10)’;

    Thanks for your help!!!
    css:
    background-color: #f0f0f0;
    width: 533px;
    height: 50px;
    margin: 0 auto 15px auto;
    padding: 30px;
    border: 1px solid #d7d7d7;
    border-radius: 11px;
    filter:progid:DXImageTransform.Microsoft.Shadow(color=#999999,direction=120,strength=10);
    behavior: url(border-radius.htc);

Leave a Reply