CSS expression Alternating color exchange _ Experience

Source: Internet
Author: User
CSS implementation, with expression but in the actual central recommended use, occupy resources and Firefox browser does not support
<style> db tr{background-color:expression (' #000000, #333333, #555555, #777777, #999999, #bbbbbb, #dddddd, # Ffffff '. Split (', ') [rowindex%8]); } </style> <table width= border= "1" class= "db" > <tr> <td> </td> </tr& Gt <tr> <td> </td> </tr> <tr> <td> </td> </tr> &LT;TR&G T <td> </td> </tr> <tr> <td> </td> </tr> <tr> &LT;TD&G t; </td> </tr> <tr> <td> </td> </tr> <tr> <td>  </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td& Gt </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr& Gt <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </ tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr& Gt <td> </td> </tr> <tr> <td> </td> </tr> <tr> &LT;TD&G t; </td> </tr> <tr> <td> </td> </tr> <tr> <td>  </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td& Gt </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr& Gt </table>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

You can change that when you're two colors.
<style>
. DB tr{
Background-color:expression (' #abcdef, #123456 '. Split (', ') [rowindex%2]);
}
</style>

<style> db {border-collapse:collapse;} . db tr{background-color:expression (' #F8F8F8, #EFEFEF '. Split (', ') [rowindex%2]);} </style> <table width= "100%" border= "1" class= "db" > <tr> <td> </td> </tr> &l t;tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> < td> </td> </tr> <tr> <td> </td> </tr> <tr> &LT;TD&GT;&NBSP;&L t;/td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> ;/tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> < tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td > </td> </tr> <tr> <td> </td> </tr> <tr> <td> < /TD> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr > <td> </td> </tr> <tr> <td> </td> </tr> <tr> &LT;TD&G t; </td> </tr> <tr> <td> </td> </tr> <tr> <td> </t d> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr > <tr> <td> </td> </tr> <tr> <td> </td> </tr> &LT;TR&G T <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td>&nbs p;</td> </tr> </table> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td>&nb Sp;</td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <t r> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td& gt; </td> </tr> <tr> <td> </td> </tr> <tr> <td> </ td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </t r> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr& Gt <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td>&nbs p;</td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </ td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </t R> </table>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

If you really want to use, you can use the following JS write
<table id= "list" width= "> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> &LT;/TR&G T <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td>&nbs p;</td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table> <script type= "Text/javascript" > <!--var colorarr = new Array ("#ffffff", "#c CCCCC "," #999999 ", "#666666", "#333333"); var s = 0; function Listdoodle () {var list = document.getElementById ("list"). getElementsByTagName ("tr"); for (var i=0;i<list.length i++) {list[i].style.backgroundcolor = colorarr[s++]; if (s== (colorarr.length-1)) {s = 0; }} window.onload = Listdoodle; --> </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.