Posts tagged with: Web Designing

Round corners with CSS3. Super Cool.

I was not very fond of CSS, until recently.  I just used html elements to style my pages. But then once I happened to use some simple CSS elements, coz I had basic CSS in my college syllabus. Ever since I’m a great fan and admirer of this simple, kewl technique.. CSS.

CSS Round Corner Menu

I have been fascinated by round cornered elements in web pages. I tried to learn the ‘secret art of round corners!!’. Most of my searches returned tutorials for rounding corners using images, Including this one. It uses 4 corner images and is pretty simple to implement.

A few days ago, I was browsing through some script from DynamicDrive CSS Library, I found an unfamiliar css element: -moz-border-radius. I did a lil research and eventually I got to CSS3. Checkout www.css3.info. CSS3 is still in draft and all browsers have not started to support it. Yet some like Firefox, Safari etc has already started to adopt CSS3.

border-radius (reference) is an element which is included in the forthcoming CSS3. It can be used in the following forms.

If you use border-radius: 4em; , then all the four corners will be rounded by 4em. Or you can use border-radius: 5px 5px 0px 10px;, so you can use individual radii for all the four corners. Or the single attribute can be broken down as follows.

border-top-left-radius: 4em;
border-top-right-radius: 4em;
border-bottom-right-radius: 4em;
border-bottom-left-radius: 4em;

The Gecko Layout Engine which is the basis of Mozilla Firefox uses some equivalent attributes instead of border-radius. The border-radius equivalent in Gecko is -moz-border-radius (reference). It can also take 4 arguments as in -moz-border-radius:15px 0px 15px 0px;. If only 1 attribute is specified as in -moz-border-radius:15px;, the same will be applied for all 4 corners. -moz-border-radius can also be written as 4 different elements as follows.

-moz-border-radius-bottomleft:15px;
-moz-border-radius-bottomright:15px;
-moz-border-radius-topright:15px;
-moz-border-radius-topleft:15px;

Here is a few examples I made which uses the -moz-border-radius element for rounding corners. See the code of the page and see how simple it is. But remember -moz-border-radius works only in Gecko based browsers, which includes Firefox, NetScape, Camino, SeaMonkey K-Meleon etc (Google’s picture-organization software Picasa is based on Gecko).

That was Kewl, ain’t it? cya, babye.