Jeepstone

The home of Pete Jones

CSS Rounded Corners (in IE6 as well!)

DD Roundies is a new slant on the age-old CSS Rounded corners functionality that amost every web designer wants, but very few have as it’s a pain to implement. Currently the options are:

Four Corners (aka Top and Tail)

In this method, the background acts as our rounded element, and we place images in elements within the container. In the simplest form, this can be just a top div, bottom div and a bit for your content. The problem with this is that it’s fixed width, which is where the 4 corners comes in allowing the container to resize. This is an acceptable, if HTML heavy way of tackling the problem as you often need more than one image to satisfy the numerous corners. Take a look at these rounded CSS corners.

Four Corners – One Image

This is a more complex CSS fix for the problem, but it’s not so good with transparent images where you need a PNG/transparency. In this instance, fluid rounded corners is a good way of acheiveing the effect and can look quite cool, despite some extra HTML. However, it’s not much use in IE6 as IE’s background positioning is pants so you need to defer to transparent GIFs, which is not much use where you have drop shadows.

Rounded CSS Corners that work in IE as well!

A little while ago I found a link to a site by Drew Diller. Drew had noticed that IE’s VML will allow you to draw a border around an HTML element. This means that you can use your nice CSS 2.1 and get rounded corners in IE. It also makes sure that it only draw the borders in IE, leaving you to implement your own rounded corners in CSS 2.1 compatible browsers such as Firefox and Safari. For instance, you could do the following:

Here is a container.

In your CSS you can put the following:

#round {
border: 1px solid #000;
-moz-border-radius:5px;
-webkit-border-radius:5px;
}

Which will give you a nice rounded box in Firefox and Safari.

You can then use Drew Diller’s script to put them in for IE. Simple!

Drawbacks

Currently, the script doesn’t support HTML form elements (it’s difficult to append HTML to a form element). However, Drew tells me that he’s working on a fix at the moment, which will be greatly received.

Tags: , ,

This entry was posted on Tuesday, December 9th, 2008 at 2:08 pm and is filed under CSS. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 Responses to “CSS Rounded Corners (in IE6 as well!)”

  1. Ashok Says:

    January 13th, 2009 at 11:55 am

    hi,
    Nice post. it ill work all the browsers except IE-6, any option for IE-6. Please let me know.
    Thanks.

  2. admin Says:

    January 13th, 2009 at 12:00 pm

    Do you mean IE5.5 and below? If so, my opinion is that they’re not worth the hassle supporting. Time spent vs benefit to user.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Jeepstone is proudly powered by WordPress 2.9.1 | Entries (RSS) | Comments (RSS).