CSS2实现的隔行换色

所属分类: 网络编程 / CSS/HTML 阅读数: 497
收藏 0 赞 0 分享
利用了CSS2 的 相邻选择符 IE7以下不支持

隔行换色示例:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>放弃class与js实现隔行换色效果</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Author" content="PengRong" />

<style type="text/css">
<!-- /* PR-CSS */
table {border-collapse:collapse;border:solid #999;border-width:1px 0 0 1px;}
table td {border:solid #999;border-width:0 1px 1px 0;}

tr {background:#eee;}
tr + tr {background:#ccc;}
tr + tr + tr {background:#eee;}
tr + tr + tr + tr {background:#ccc;} 
tr + tr + tr + tr + tr {background:#eee;} 
-->
</style>
</head>

<body>
<table>
<tr>
<td>12</td><td>12</td><td>12</td><td>12</td>
</tr>
<tr>
<td>12</td><td>12</td><td>12</td><td>12</td>
</tr>
<tr>
<td>12</td><td>12</td><td>12</td><td>12</td>
</tr>
<tr>
<td>12</td><td>12</td><td>12</td><td>12</td>
</tr>
<tr>
<td>12</td><td>12</td><td>12</td><td>12</td>
</tr>
</table>
</body>
</html>




隔列换色示例: 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>放弃class与js实现隔列换色效果</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Author" content="PengRong" />

<style type="text/css">
<!-- /* PR-CSS */
table {border-collapse:collapse;border:solid #999;border-width:1px 0 0 1px;}
table td {border:solid #999;border-width:0 1px 1px 0;}

td {background:#eee;}
td + td {background:#ccc;}
td + td + td {background:#eee;}
td + td + td + td {background:#ccc;} 
td + td + td + td + td {background:#eee;} 
-->
</style>
</head>

<body>
<table>
<tr>
<td>12</td><td>12</td><td>12</td><td>12</td>
</tr>
<tr>
<td>12</td><td>12</td><td>12</td><td>12</td>
</tr>
<tr>
<td>12</td><td>12</td><td>12</td><td>12</td>
</tr>
<tr>
<td>12</td><td>12</td><td>12</td><td>12</td>
</tr>
<tr>
<td>12</td><td>12</td><td>12</td><td>12</td>
</tr>
</table>
</body>
</html>
更多精彩内容其他人还在看

IE 5.x/Win 和模型bug

IE 5.x/Win 和模型bug
收藏 0 赞 0 分享

各浏览器padding、margin的差异

各浏览器padding、margin的差异
收藏 0 赞 0 分享

IE浮动边界BUG延伸探讨

IE浮动边界BUG延伸探讨
收藏 0 赞 0 分享

[转]目前找到的最好的Iframe自适应高度代码

[转]目前找到的最好的Iframe自适应高度代码
收藏 0 赞 0 分享

Web Safe Color Pallette

Web Safe Color Pallette
收藏 0 赞 0 分享

网站制作之网页技巧

网站制作之网页技巧
收藏 0 赞 0 分享

http状态码一览表

网站的http状态对于网站维护人员来说是相当重要的,当网站出现问题的时候,我们首先要诊断一下网站的http状态,从而进一步确认哪里出现的问题
收藏 0 赞 0 分享

从Table向Css过渡的优缺点比较

从Table向Css过渡的优缺点比较
收藏 0 赞 0 分享

不用float实现div模块居中布局

不用float实现div模块居中布局
收藏 0 赞 0 分享

解决列高度自适应(相同)的五种方法

解决列高度自适应(相同)的五种方法
收藏 0 赞 0 分享
查看更多