zoukankan      html  css  js  c++  java
  • css控制表格交替颜色

    奇妙的样式表语法
     <style type="text/css">
     
    <!--
     tr 
    {background-color:expression((this.sectionRowIndex%2==0)?"red":"blue")}
     td 
    {background-color:expression((this.cellIndex%2==0)?"":((this.parentElement.sectionRowIndex%2==0)?"green":"yellow"))}
     
    -->
     
    </style>
     
    </HEAD>
     
    <table>
     
    <tr><td>第1行</td><td>第1行</td><td>第1行</td><td>第1行</td><td>第1行</td></tr>
     
    <tr><td>第2行</td><td>第2行</td><td>第2行</td><td>第2行</td><td>第2行</td></tr>
     
    <tr><td>第3行</td><td>第3行</td><td>第3行</td><td>第3行</td><td>第3行</td></tr>
     
    <tr><td>第4行</td><td>第4行</td><td>第4行</td><td>第4行</td><td>第4行</td></tr>
     
    <tr><td>第5行</td><td>第5行</td><td>第5行</td><td>第5行</td><td>第5行</td></tr>
     
    </table>
     
    //myhyli @ blueidea
     


    控制鼠标移动颜色
    <style>
    tr
    {background-color:expression((this.rowIndex%2==0)?"blue":"red");ryo:expression(onmouseover=function(){this.style.backgroundColor=(this.style.backgroundColor!='gray'?'gray':((this.rowIndex%2==0)?"blue":"red"))},onmouseout=function(){this.style.backgroundColor=(this.style.backgroundColor!='gray'?'gray':((this.rowIndex%2==0)?"blue":"red"))})}
    </style>
    <TABLE width="200" cellpadding="0" cellspacing="2" border="0" id="t1">
    <TR>
    <TD>&nbsp;</TD>
    </TR>
    <TR>
    <TD>&nbsp;</TD>
    </TR>
    <TR>
    <TD>&nbsp;</TD>
    </TR>
    <TR>
    <TD>&nbsp;</TD>
    </TR>
    <TR>
    <TD>&nbsp;</TD>
    </TR>
    <TR>
    <TD>&nbsp;</TD>
    </TR>
    <TR>
    <TD>&nbsp;</TD>
    </TR>
    <TR>
    <TD>&nbsp;</TD>
    </TR>
    </TABLE>
  • 相关阅读:
    P1012拼数
    P1622释放囚犯
    P1064 金明的预算方案
    P1754球迷购票问题
    卡塔兰数
    P1474货币系统
    P2562kitty猫基因
    P3984高兴的津津
    5-servlet简介
    java通过百度AI开发平台提取身份证图片中的文字信息
  • 原文地址:https://www.cnblogs.com/yg_zhang/p/570489.html
Copyright © 2011-2022 走看看