Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become an Expert!

Join 244,301 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 774 people online right now. Registration is fast and FREE... Join Now!




Rounded Corners Without Images!

 
Reply to this topicStart new topic

> Rounded Corners Without Images!, CSS code for corner radius (Moz Only)

Speechist
Group Icon



post 24 Feb, 2006 - 11:58 PM
Post #1


There is a cool way to get rounded corners on your containers (DIV or whatever) of almost any size/dimension (radius) without using a single image. The good folks at Mozilla have provided us support for this CSS standard (sorry, IE hasn't caught up to this yet, and I'm not sure IE7 will either...if someone has newer info on this, please post).

The code is actually painfully simple. Just define the amount of radius you want for a given corner of a container's style declaration:

CODE
#inner {
    width:200px;
    float:left;
    margin-right:2%;
    border:3px solid #D6D6C2;
    background:#E0E9F8;
    padding: 3px;
    font: 12px Verdana, Arial, Helvetica, sans-serif;
    -moz-border-radius: 15px 0 15px 0;
}


Of course in the
CODE
<body>
you would attach the #inner declaration to a DIV:
CODE
<div id="inner">Here is some content</div>
or other container element.

In this instance, we've defined an ID declaration called "inner" with a certain width, floated it left, gave it a bit of a margin all around, a border, padding and a font. But if you look closely at the last item, you'll notice a definition for the amount of radius for the border. The convention here for the 4 numbers is: upper-left, upper-right, lower-right, lower-left. In this case, we've got a nice 15px radius on the upper-left and lower-right corners. Cool! To see this in action, take a look at the following page:


RRHS B & E Academy

Be sure you're looking at this in Firefox to see the effect. In IE, it just ignores the code and renders nice square corners. Very imaginitive Bill.

Anyway, have fun with this and keep hoping IE will catch up some day!

This post has been edited by Speechist: 25 Feb, 2006 - 01:13 AM
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!

im@geek
Group Icon



post 20 Mar, 2006 - 04:59 PM
Post #2
Will this work with Safari?
Go to the top of the page
+Quote Post

im@geek
Group Icon



post 20 Mar, 2006 - 05:01 PM
Post #3
I answered my own question, Yes this does work with safari!
Go to the top of the page
+Quote Post

danielle_1_uk
Group Icon



post 25 Mar, 2006 - 01:23 PM
Post #4
QUOTE(Speechist @ 25 Feb, 2006 - 04:50 AM)
Be sure you're looking at this in Firefox to see the effect.  In IE, it just ignores the code and renders nice square corners.  Very imaginitive Bill.

Anyway, have fun with this and keep hoping IE will catch up some day!

Nice!

I am all for cross-browser compatibility but instead I'm going hope that IE maintains its Fischer-Price "My first Browser" status...and feel safe in the knowledge that more and more people are beginning to realise this.

EDIT: At least mozilla use "-moz-" as a prefix for all their proprietary CSS properties and values, which follows the W3C's standards. But of course, IE doesn't adhere to this - Microsoft it seems choose to name their vendor specific tags anything they feel like mad.gif

For a few more mozilla ones, and how they're supported, check out:
http://www.blooberry.com/indexdot/css/prop...sextensions.htm

...roll on CSS3

This post has been edited by danielle_1_uk: 25 Mar, 2006 - 01:34 PM
Go to the top of the page
+Quote Post

michelle@urban
Group Icon



post 25 Mar, 2006 - 01:43 PM
Post #5
QUOTE(danielle_1_uk @ 25 Mar, 2006 - 09:15 PM)
I am all for cross-browser compatibility but instead I'm going hope that IE maintains its Fischer-Price "My first Browser" status...and feel safe in the knowledge that more and more people are beginning to realise this.

I sure hope so! The whole cross compatibility thing between IE and Firefox from a graphics point of view is just a pain in the arse, is there anyway to make them view the page the same way? NO! Arghhhh.

Down with IE tongue.gif
Go to the top of the page
+Quote Post

Arbitrator
Group Icon



post 5 Jun, 2006 - 10:10 PM
Post #6
The caveat to using this property is that any background image you use will not be rounded by this property; the background will still have the normal 90 degree angular corners that you're used to except that it'll look out of place with the rounded corners. This effectively limits you to using a solid color background, a transparent background, or a pre-built image to match the current rounded borders. Also, you need to specify padding that exceeds the space subtracted from the corners or your box contents will overlap the border in this area.

It should also be noted that this is a Mozilla-specific CSS property. As such it should work in any Mozilla-based browser such as Firefox and Netscape. If it works in Safari, that must be based on Mozilla as well.

The property is based on the W3C's CSS3 Backgrounds and Borders Module: Border Radius which is currently in draft status, so you can't blame Internet Explorer for not supporting it. Browsers aren't required to support specifications until they reach the status of "recommendation". Also note that the Mozilla implementation doesn't actually match the specification either.

Of course, this code shouldn't really hurt anything so there shouldn't be any problems using it as long as you keep in mind that only Mozilla users will see it.
Go to the top of the page
+Quote Post

MsAne
*



post 12 Jun, 2008 - 01:59 PM
Post #7
wow this is real neat, theres alot of other neat things in css but ofcourse we always have the broswer compatibility issue GRRRRRRRRRRRRRRR!
Go to the top of the page
+Quote Post

shweta.honey25
*



post 14 Oct, 2008 - 12:26 AM
Post #8
hi its working on safari,firefox but not working on IE6
give reason and solution plz that why its not working
Go to the top of the page
+Quote Post

Thunderchild
*



post 18 Dec, 2008 - 08:59 AM
Post #9
Thanks this worked well for me in FF, but as been said before it doesnt work in IE7
Go to the top of the page
+Quote Post

wltrbe
*



post 22 Mar, 2009 - 07:56 PM
Post #10
awesome.
Go to the top of the page
+Quote Post

Adryi19
*



post 31 Mar, 2009 - 02:59 PM
Post #11
Of course.. Awesome icon_up.gif
Go to the top of the page
+Quote Post

vergun
*



post 7 Apr, 2009 - 06:19 PM
Post #12
does this work on chrome and/or opera?
Go to the top of the page
+Quote Post

ultimateweb
*



post 27 Jun, 2009 - 12:16 AM
Post #13
This only works in mozilla,safari and IE 8 because they support CSS 3.0
Go to the top of the page
+Quote Post


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 


Lo-Fi Version Time is now: 7/4/09 05:28PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month