Words from Alejandro U. Alvarez
CSS3 New features – Interesting info ;)
Hello fellow developers,
I'm sure all of you have heard of the "new" CSS3 stuff, it's been around for a while now, and it certainly has some very interesting new features.
First, I'll review some of the things that were the hardest to develop, yet they looked so damn well:
- Rounded corners - We all love them, but how hard is to find a good way to do them?
- Alpha transparency - PNGs, JavaScript tweaks... I must admit they are hard...
Plus, I'll show you how to create rounded+transparent borders!
Conclusion: The world needs new CSS features:
Solution: CSS3
Let's get going
Now before we get too exited, take into account that these new features "work" on major browsers, except obviously IE. So I would never use them for client sites... Meaning that you should only use these for personal designer portfolios, where you want to impress colleagues.
So now that this was clear, let's see how the new stuff goes:
Rounded corners:
For this you only have to select the element and use the following CSS code:
#example{ -moz-border-radius: 20px; -webkit-border-radius: 20px; }
Demonstration:
CSS for the example:
background-color:#FFFFFF; border:#CCCCCC solid 2px; -moz-border-radius: 20px; -webkit-border-radius: 20px; padding:30px; text-align:center;
For more options go to the official CSS3 specs page for rounded corners
Transparency
This one is one of my favorites, combined with rounded corners
The way it works is simple, you can make any background color transparent by using one of several methods, I will show you the one I consider the easiest.
You know how in normal CSS we can select colors via the RGB color code, as in:
color: rgb(0,0,0);
Well, in CSS3 we can now add a fourth parameter, that will contain the alpha information, from 0 to 1.
Demonstration:
CSS for the example above:
background-color:rgba(0,0,0,0.5); color:#000; padding:30px; margin:20px; border:#CCCCCC solid 2px; text-align:center;
This effect won't look as cool here, because the background is a plain color. Use it over textured backgrounds for a great effect!
Rounded+transparent borders!
These really look amazing, rounded, transparent borders! Take a look at a live example
Unluckily, we cannot use rbga() colors on borders, but there is a simple workaround, embed the div you want with another one, with a padding of the size of the border (It looks better with larger borders)
Demonstration:
CSS for the example above:
DIV 1 (Outer div) - Note the bigger radius
margin:20px; padding:20px; background-color:rgba(0,0,0,0.5); -moz-border-radius: 30px; -webkit-border-radius: 30px;
DIV 2 (Inner div)
padding:20px; text-align:center; background-color:#FFFFFF; color:#333333; -moz-border-radius: 20px; -webkit-border-radius: 20px;
Well, I hope you found this interesting!
Show us your uses!
Have you already implemented any of these techniques? Please show us!
Comment below with the URL of the site where you used the new features of CSS3
| Print article | This entry was posted by alex on June 11, 2009 at 9:21 pm, and is filed under CSS, Graphic Design, Layout/Styling, Web-related. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
No comments yet.
No trackbacks yet.
iPhone web development [Part 2]
about 3 months ago - No comments
In part one of my tutorial on iPhone web development, we talked about the basic stuff (Recognizing iPhones or iPods, setting up special HTML and CSS tags… ) we will now move on to the really clever bit: Orientation detection.
For many sites, we may just have the same thing both on portrait and landscape. But More >
Fast and dirty CSS trick for IE
about 5 months ago - No comments
I actually think that we the developers need IE, it is like the bad guy in an action movie, the good guy wouldn’t have a life without him, although sometimes you really wish it never existed! Haha just kidding, we all wish it didn’t exist… But well, there are some times when we need something More >
Stylish CSS trick for your Website
about 10 months ago - No comments
Maybe a few of you noticed this on some websites, maybe some of you even use it.
Right now this works in Safari, Opera, and Konqueror and Firefox 3.x. (I think it doesn’t work in Firefox 1 or 2, correct me if I’m wrong)
What I’m talking about is the text-shadow, wisely applied to your design, it More >
Apply a background image to an image
about 1 year ago - No comments
this is quite a neat trick, and it can look really good depending on your design and the image you put as background…
To get it to work all you need is to apply a padding and display:block; to the image. So the CSS would be:
img{
display:block;
padding:10px;
background-image:url(image.gif);
}
Here is a very smart use of this technique, where a More >
How we became web developers…
about 2 years ago - 3 comments
I normally write to those web developers/programmers who are already good, experienced, and thus the articles are somewhat advanced.
But today I got up feeling nostalgic I guess, or I just felt like remembering back on my www birth, on my first impression of the Internet, my first site online, my first steps in w3c standards, More >
Beautiful tab design:
about 2 years ago - No comments
This article is not on how to create tabbed menus, is just about how to style them!
I completely forgot who was the source, so if you happen to be the author comment your URL and I’ll put up a link
Anyway, I found that this is by far the easiest and probably most beautiful More >
Reseting CSS default browser settings:
about 2 years ago - 6 comments
One of the biggest problems when designing a website is that after all work is done it looks different on different browsers.
The solution usually used by most web developers consists on manually changing every bit of CSS they have to make it look all the same, resulting on a very hard and time-consuming approach.
A great More >
New version of the nifty corners script
about 2 years ago - 1 comment
I’m sure you’ve heard of the Nifty Corners js script to create very cool rounded corners, and some of you might even have used it, well there is a new version:
Nifty Corners Cube
It improves most flaws of the first version, plus it adds new features and functionalities. This is the new stuff:
The numbers of parameters More >
Keeping up with my redesign
about 2 years ago - 2 comments
As I posted in my previous post I’m redesigning my blog, so I have finally finished my PhotoShop draft and started coding it.
The HTML is pretty straight forward, a few layers, floated divs and intelligent use of margins and paddings… if it can deserve the use of intelligent.
Here you can see the development page:
http://urbanoalvarez.es/test/
I’m still More >
Urbano’s Blog redesign
about 2 years ago - No comments
Hi guys,
Urbano’s Blog has been around enough time to get some very decent monthly traffic, and I personally think that it deserves a new design/redesign.
I’m thinking of a nice CSS/Artwork design, with high-contrast colors, and nice combinations.
Some of the design ideas I’ve been looking at are this:
Cheb 2.0
Decadora
Lucid Motives (Just the colors in this one… More >