top | item 1608930

Make CSS3 buttons that are extremely fancy

117 points| ssclafani | 15 years ago |technology.posterous.com | reply

32 comments

order
[+] coderdude|15 years ago|reply
How hard is it to upload a demo page? I can't stand CSS tutorials with screenshots or images as a demo.
[+] jjcm|15 years ago|reply
http://jjcm.org/css3-buttons/ Here's a demo page. I agree though, ridiculous that it didn't include one.

edit - tried them in IE6/7, they don't degrade that gracefully. They exist and work fine as buttons, but visually it's hard to tell that they are. If you use this I'd recommend adding a :hover on the span's background color as well just so a user knows to click the thing.

[+] photon_off|15 years ago|reply
That's pretty annoying. Up there with company blogs that don't actually link to the company website.
[+] Griever|15 years ago|reply
These are nice, but I still find that Zurb's example's are still the best out there.

http://www.zurb.com/article/266/super-awesome-buttons-with-c...

I use them on nearly all of my projects.

[+] bemaniac|15 years ago|reply
The main difference is that these buttons require no images, while the Zurb ones still require an image. The lack of images makes the buttons highly scalable.
[+] aaroneous|15 years ago|reply
I know that article is a little old so it advocates a png, but today Safari, Chrome, IE and Moz all support gradients (albeit each in their own way).
[+] bradgessler|15 years ago|reply
For those SaSS fans out there checkout compass's CSS3 gradient helpers (http://compass-style.org/docs/reference/compass/css3/gradien...). Compass does not include the dx filters, but that would be an excellent thing for that lib to support.

Also, the markup Posterous uses is more verbose than it needs to be. We figured out a way use plain 'ol <button/> or <a/> tags and style them as buttons. Maybe I'll blog about that when we roll this stuff out.

Visually, those buttons look good.

[+] Eugene3v|15 years ago|reply
This looks very cool, however it doesn't seem to work in IE... :(
[+] seanalltogether|15 years ago|reply
Something about the corners of the button are really bugging me.
[+] jws|15 years ago|reply
Concur. Those lower corners have serifs on the first two and gaps on the third.
[+] amadiver|15 years ago|reply
It's kinda strange to me that CSS devs (designers? devigners?) would violate DRY in such an egregious way every time they want to create a gradient:

    background: -webkit-gradient(linear, left top, left bottom, from(rgba(220,220,220,0.6)), color-stop(0.5, rgba(100,100,100,0.2)), color-stop(0.5, rgba(0,0,0,0.21)), to(rgba(0, 0, 0, 0.20))); 
    background: -moz-linear-gradient(top, rgba(220,220,220,0.6), rgba(100,100,100,0.2) 50%, rgba(0,0,0,0.21) 50%, rgba(0, 0, 0, 0.20));
    filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#99dcdcdc', endColorstr='#33000000'); 
I don't work with CSS extensively; is there a better way?
[+] josefresco|15 years ago|reply
I love how the author includes a line within the article that pretty much sums up the insanity of using pure CSS to create buttons ... "a small truckload of CSS" A designer could replace that truckload of CSS with 1 image and 1 line of code.

We gotta stop sometimes and think .. what are we trying to achieve exactly? Strikes me almost as an extreme diet that excludes 100% of fat from your intake just for the sake of having no fat irregardless if it's healthy or causes you to lose weight.

But in the "cool project" nerdy line of thinking .. it's pretty neat.

[+] amackera|15 years ago|reply
Well for one thing the buttons are scalable, unlike images. Also I imagine that the truckload of CSS still comes in way smaller than the required image(s).

If someone's willing to take the time to figure it out, it is not wasted. If indeed it is more efficient to draw buttons this way than to use an image, it makes sense to do this.

[+] ugh|15 years ago|reply
Three images, actually (normal, hover and active). Six if you have buttons in two different colors. Twelve if you need the buttons in two different sizes.

You need a truckload of CSS to define how a button looks but you only need to do it once. Creating arbitrarily colored and sized buttons is as easy as adding one or two lines of CSS. And at some point in the future we will actually be able to drop the prefixes and the CSS will become quite elegant and compact.

[+] wmeredith|15 years ago|reply
This is a great article, thanks for sharing.
[+] metamemetics|15 years ago|reply
> Made with pure CSS3

False. Webkit extensions, mozilla extensions, and internet explorer extensions are NOT pure CSS3. They are ugly browser hacks. This is hard-coded to only work on the Big 3 and will never work on Opera, thanks for not supporting browser freedom.

[+] ubernostrum|15 years ago|reply
These are vendor-prefixed implementations of features which are present in the current drafts of future editions of the relevant standards. As such, they are neither an "ugly browser hack" nor an attack on "freedom"; in fact, this is the way it's supposed to happen. Once the standards go final and the browsers get compliant implementations, the vendor prefixes will go away.

So... how about you get that big chip off your shoulder and let people get on with their work?