CSS控制表格的交替颜色三例

<style type="text/css">
<!--
tr {background-color:e­xpression((this.sectionRowIndex%2==0)?"red":"blue")}
-->
</style>
</HEAD>
<table>
<tr><td>第1行</td><td>第1行</td></tr>
<tr><td>第2行</td><td>第2行</td></tr>
<tr><td>第3行</td><td>第3行</td></tr>
<tr><td>第4行</td><td>第4行</td></tr>
<tr><td>第5行</td><td>第5行</td></tr>
</table>
//myhyli @ blueidea

<style type="text/css">
<!--
tr {background-color:e­xpression((this.sectionRowIndex%2==0)?"red":"blue")}
td {background-color:e­xpression((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:e­xpression((this.rowIndex%2==0)?"blue":"red");ryo:e­xpression(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>111</TD>
</TR>
<TR>
<TD>222</TD>
</TR>
<TR>
<TD>333</TD>
</TR>
<TR>
<TD>444</TD>
</TR>
<TR>
<TD>555</TD>
</TR>
<TR>
<TD>666</TD>
</TR>
<TR>
<TD>777</TD>
</TR>
<TR>
<TD>888</TD>
</TR>
</TABLE>


评论: 0 | 引用: 0 | 查看次数: 4593
发表评论
登录后再发表评论!