CSS中的隔行换色

一.表格的<tr>隔行换色
 <style type="text/css">
<!--
tr {background-color:expression((this.sectionRowIndex==0)?"":
(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>
二.表格的td换色
 <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>
三.Li标签隔行换色代码
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
.t1 {background-color:#336699;text-align:center}
.t2 {background-color:#ffcc00;text-align:center}
ul{list-style:none;width:200px;}
ul li{height:20px;line-height:20px;width:200px;}
</style>
<script>
<!-- POPOEVER is drinking half bottle of lemon tea:) --
function ulLi() {
for (i=1;i<bkg1.children.length+1;i++) {
(i%2>0)?(bkg1.children(i-1).className = "t1"):(bkg1.children(i-1).className = "t2");
}
}
//-- Lemon tea is bottom up -->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onLoad="ulLi();">
<ul id="bkg1">
<li>li背景变变变</li>
<li>li背景变变变</li>
<li>li背景变变变</li>
<li>li背景变变变</li>
<li>li背景变变变</li>
<li>li背景变变变</li>
<li>li背景变变变</li>
<li>li背景变变变</li>
</ul>
</body>
</html>

出自: http://www.blogjava.net/liuwentao253/archive/2007/08/07/134903.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值