Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradient alpha fade out effect with CSS 3

Tags:

html

css

gradient

I would like to know if it would be possible to replicate the effect like the bottom of the Top Tweets list with pure CSS?

http://www.twitter.com

like image 392
Rana Avatar asked Aug 22 '10 23:08

Rana


1 Answers

Yes you can! Taking advantage of RGBa colors and CSS3 gradients, we can apply the following styles to an element and have a fading semi-transparent background:

Mozilla:

background: -moz-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255, 1));

Webkit:

background: -webkit-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255, 1));

(Updated after changes to Webkit gradients)

Sadly, this only works in Firefox 3.6+, Safari, and Chrome. If you need the effect in IE or older versions of Firefox, then you'd be better off using the semi-transparent PNG like Twitter does.

like image 125
derekerdmann Avatar answered Nov 05 '22 14:11

derekerdmann