How to create zebra stripes on html table without using javascript and even/odd classes generation?

后端 未结 5 1518
情话喂你
情话喂你 2020-12-08 01:54

I want to zebra-stripe a html table without using any js stuff or writing server-side code to generate even/odd classes for table rows. Is it ever possible to do using raw c

5条回答
  •  春和景丽
    2020-12-08 02:20

    If all you're changing is the background colour, then the following would work, where test.gif is a 40px high image with the top 20px one colour, and the bottom 20 pixels the other colour. If you need to change any other css properties you're pretty much stuck.

    table {  background: url(test.gif) top; }
    table tr { height: 20px; }
    

提交回复
热议问题