Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css zebra stripe background without image

Tags:

css

possible to use css to have zebra stripe as background without using image?

like image 890
cometta Avatar asked May 19 '26 06:05

cometta


1 Answers

Yes you can, with something like

ul li {
   background-color: #fff;
}

ul li:nth-child(even) {
   background-color: #efefef;
}

See:
http://reference.sitepoint.com/css/pseudoclass-nthchild
http://reference.sitepoint.com/css/understandingnthchildexpressions


Edit

You really should've stated clearly what you meant by zebra strips ;)

If you need gradient backgrounds without using images, see:

http://www.webdesignerwall.com/tutorials/cross-browser-css-gradient/

Basically, the syntax you'll be using will look something like:

background-image: -moz-linear-gradient(left, #fff, #999);
background-image: -webkit-gradient(linear, #fff, #999);

See:
https://developer.mozilla.org/en/CSS/-moz-linear-gradient
http://webkit.org/blog/175/introducing-css-gradients/

For more details

like image 56
Yi Jiang Avatar answered May 22 '26 01:05

Yi Jiang