![]() |
How do I create CSS3 rounded corners and drop shadows?I want to start experimenting with CSS3 on my Web site and would like to start with rounded corners and drop shadows, both of which would be mondo cool to include on my site. Is it too soon? If not, how do I create CSS3 border radius containers? Ah, the ugly mess that is the evolution of Web standards. Whether it's HTML5 or CSS3, both are slowly and painfully becoming standards, but in the meantime, it turns out that there's much debate and contention about even the simplest of features. Like rounded corners. In the CSS3 spec, rounded corners are specified as border-radius: though it's implemented differently in the Mozilla family of browsers (including Firefox) than the Webkit (Safari) group. What this means is that if you're running, say, Internet Explorer or an older version of one of these browsers, odds are good you won't see anything happen when you specify the right CSS attribute. Here's an example: This should be a box with nicely rounded corners.
The code for this to work is: <div style="background-color:#ccf;padding:8px;border:2px solid black;border-radius:10px;">This should be a box with nicely rounded corners.</div>
Not too bad to use, but why they can't just accept "border-radius", well, that's part of the adventure of web standards, I suppose. Now, what about a drop shadow? That's done with the css attribute box-shadow, which takes three parameters: horizontal offset of the shadow, vertical offset of the shadow, blur factor and color. Complicated, eh? Here's how it could be used in cooperation with the earlier rounded box: This should be a box with nicely rounded corners.
Bet there's no shadow, though. Turns out that there's great debate about how to implement box shadow, so in fact you need to match the CSS3 model of your browser for it to even have a possibility of working. Like this: This should be a box with nicely rounded corners and a drop shadow.
Did that work for you? If you're on a modern browser it probably did. Cool, right? Yeah, except here's the CSS3 required to make this work: Here's the code I'm using for this to work: <div style="background-color:#ccf; padding:8px; border:2px solid black; border-radius:10px; box-shadow: 8px 8px 4px #666;-o-box-shadow: 10px 10px 5px #888;-icab-box-shadow: 10px 10px 5px #888;-khtml-box-shadow: 10px 10px 5px #888;-moz-box-shadow: 10px 10px 5px #888;-webkit-box-shadow: 10px 10px 5px #888;box-shadow: 10px 10px 5px #888;">This should be a box with nicely rounded corners and a drop shadow.</div>
More than a bit of work, but at least it does render properly in modern browsers, and that's pretty darn slick. Keep track of what's happening in the world of CSS3 by tracking http://www.css3.info/ too.
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon
Categorized:
HTML and CSS
(Article 9506)
Tagged: css, css3, firefox, mozilla, safari, standards, web browsers, webkit Previous: How do I reset my Amazon Kindle DX to factory defaults? Next: Can I omit songs from my iPhone spotlight search results? View Mobile Version Subscribe!
Rather amazingly, there are no comments on this article yet.
I have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
Recommended
Recent Entries
Search
I Need Help!
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above Facebook Help HTML and CSS Industry News and Trade Shows Mac OS X Help MySpace, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help |