CSS实现表格数据行按照奇偶行区分背景颜色显示.docVIP

  • 0
  • 0
  • 约1.82千字
  • 约 5页
  • 2017-06-10 发布于北京
  • 举报

CSS实现表格数据行按照奇偶行区分背景颜色显示.doc

当鼠标经过表格数据行时颜色不同且奇偶行颜色也不同 来源:互联网 作者:佚名 时间:07-16 17:37:00 【大 中 小】 想必大家都有遇到过这样的效果,就是当鼠标经过时颜色不同,且奇偶行颜色也不同,此鼠标响应效果在css中也可以实现,下面有个不错的示例代码,需要的朋友可以参考下 复制代码 代码如下: !DOCTYPE html !-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. -- html head meta http-equiv=Content-Type content=text/html; charset=utf-8 / link href=table.css type=text/css rel=stylesheet / titletable test/title !-- style table tbody tr:hover{ background-color: #EEECEB; } /style -- /head body table tr th姓名/th th性别/th th班级/th /tr tbody tr td姓名/td td男/td td计算机科学与技术一班/td /tr tr td段萌/td td男/td td软工一班/td /tr tr td段萌/td td男/td td软工一班/td /tr tr td段萌/td td男/td td软工一班/td /tr tr td段萌/td td男/td td软工一班/td /tr /tbody /table /body /* To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. */ /* Created on : 2014-7-9, 14:24:31 Author : Administrator */ body{ margin:0 auto; text-align:center} /*设置表头的margin为0则表居中显示,border为0则无边界*/ table{margin:0 auto; border:0px; solid:#000 } /*设置th表头的属性,font-weight为bold则显示为黑粗*/ table tr th{ height:28px; width: auto; line-height:28px; background:#999; font-weight:bold } table tbody tr{ height:28px; line-height:28px; text-align:center; background:#FFF; vertical-align:middle; } /* *设置鼠标经过颜色的变化 */ /*采用csss的这个方法,获得奇数行,让后设置其属性,这样避免使用expression这个容易出错的方法*/ table tbody tr:nth-child(odd){ background-color: #DEDEDE } table tbody tr:hover{ background-color: #CCCCCC; }

文档评论(0)

1亿VIP精品文档

相关文档