It's No Longer Hip to be Square

• Written by: Mike on January 25, 2012

One of the great things about CSS3 is the ability to create rounded edges on borders on anything. Images, navigation items, tabs, you name it. No longer are we stuck with square boxes or complex developing to display rounded edges. Contrary to Huey Lewis and the News, its no longer hip to be square.

Rounded corners display in all major browsers.

IE 6, 7, and 8 do not display rounded corners.

 

Border Radius

The border radius allows us to round the corners of elements using only CSS. Each corner is treated as a quarter ellipse, which is defined by a curve that is drawn between a point on the x-axis and a point on the y-axis. The ellipse can look like a quarter circle, or a stretched quarter circle.

To create a 10px border radius on all image corners use the following css:

img {border-radius: 10px;}

Sometimes you will need to style each corner differently.

 

General Syntax

div {border-v-h-radius: x y;}
div {border-top-right-radius: 5px 10px;}
div {border-top-left-radius: 5px 10px;}
div {border-bottom-right-radius: 5px 10px;}
div {border-bottom-left-radius: 5px 10px;}

If you want each corner to be a quarter circle of different sizes, you can used the shorthand styling. The radii starts at the top-left corner and rotates clockwise around the element.

 

Shorthand

div {border-radius: top-left, top-right, bottom-right, bottom-left;}
div {border-radius: 1px 2px 3px 4px;}

If you want each corner to have the same radius , there is an even shorter hand version.

 

Super Shorthand

div {border-radius: 5px;}

As you can see, there is a fair bit of options with border radius.  As long as you arent using Internet Destroyer (aka Internet Explorer), border-radius will work quite nicely.

You also may be wondering who Huey Lewis is.  Below may clarify things.

Huey Lewis And The News - Hip To Be Square

Let's Talk

Toll-Free: 1-855-623-2255 (Mad-Call)

Fax: 1-855-623-3299 (Mad-Faxx)
Main Local: 226-444-0434
Tech Support: 226-444-0438

 madmail@madhattertech.ca

@MadHatterTech

  • Excellent video describing the shift in marketing from 20th to 21st century. Time to understand content marketing: http://t.co/lNx2OWg6 1 hour 26 min ago
  • Congratulations #ConestogaCollege students for National Award! http://t.co/uxszM3Or 11 hours 5 min ago
  • “Those in middle management... found innovation disruptive to their day-to-day activities” http://t.co/b5Uzz9QO vs. innovate or die? 1 day 5 hours ago

Find us on Facebook

Great spirits have always encountered violent opposition from mediocre minds.
Albert Einstein
1879 - 1955
Swiss-German-US Physicist