用VS 2013 F5跑起来看,有相间的效果
但网页放到IIS上时,就没有了.
查到原因是因为IE浏览时预设值为版本7,这个功能要9 以上才支援.
所以就再加上
<%--预设IE版本为9,相容到11--%>
这样如果USER有安装9以上,就会预设9了!!
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=9; IE-11"/><%--预设IE版本为9,相容到11--%> <style type="text/css"> .myTable tr:nth-child(even) { background: #ffecec; } .myTable tr:nth-child(odd) { background: #e8d0d0; } </style> <title></title></head><body> <table class="myTable"> <tr> <td>xxxx</td> <td>xxxx</td> <td>xxxx</td> </tr> <tr> <td>xxxx</td> <td>xxxx</td> <td>xxxx</td> </tr> <tr> <td>xxxx</td> <td>xxxx</td> <td>xxxx</td> </tr> <tr> <td>xxxx</td> <td>xxxx</td> <td>xxxx</td> </tr> <tr> <td>xxxx</td> <td>xxxx</td> <td>xxxx</td> </tr> </table></body></html>