当鼠标经过表格数据行时颜色不同且奇偶行颜色也不同 (纯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=gb2312" /> <title>table test</title>
<style> /*
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;
}
</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>
</html>
当鼠标经过表格数据行时颜色不同且奇偶行颜色也不同 (纯CSS)的更多相关文章
- 如何修改antd中表格的表头样式和奇偶行颜色交替
在做antd表格时通常会用到table组件,但是table的表头时给定的,那么怎么修改表头的颜色呢? 这里用的时less的写法,在全局环境中写,所有的table表头都会变成自己定义的颜色 定义好表头的 ...
- html table奇偶行颜色设置 (CSS选择器)
:nth-child(n) 选择器匹配属于其父元素的第 N 个子元素,不论元素的类型.n 可以是数字.关键词或公式. 下面的例子, 设置表格的奇偶行背景颜色不同:单独设置表格的第1列背景颜色不同. & ...
- table中嵌套table,如何用jquery来控制奇偶行颜色
总是要趁着自己还有记忆的时候,把该记录下来的都记录下来,着实是不敢恭维自己的记性. 相信很多时候,我们前端人员,经常会用到table里面的某个td中还嵌套着table,而这个时候还总要去弄奇偶行的颜色 ...
- tab奇偶行颜色交替+插件
(function($){ $.fn.tableUI=function(options){ var defaults={ evenRowclass:"evenRow", oddro ...
- flex 4 datagrid 奇偶行颜色设置
<s:DataGrid width="100%" height="100%" alternatingRowColors="[#ffFFff,#e ...
- Bootstrap table插件 被选中的行颜色改变
参考:https://www.jianshu.com/p/1bb4c37ef636 在 bootstrap-table.min.css 中修改源码 //选中行颜色 .fixed-table-conta ...
- JS实战 · 表格行颜色间隔显示,并在鼠标指定行上高亮显示
思路: 1.获取所有行对象,将需要间隔颜色显示的行对象进行动态的className属性指定: 前提是:先定义好类选择器,就是说给行对象赋予name. 2.高亮用到两个事件:onmouseov ...
- table 控制单双行颜色以及鼠标hover颜色 table光棒
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 如何在Word表格中的某一栏添加背景颜色
如何在Word表格中的某一栏添加背景颜色 编写人:CC阿爸 2014-3-14 用鼠标选中某一个单元格然后右键单击 下拉菜单选择.<边框和低纹>然后点<低纹>选项卡 选中色卡 ...
随机推荐
- adaboost 参数选择
先看下ababoost和决策树效果对比 import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection ...
- response导出Excel(一个新手的记录,可以时常查看,以免自己忘记)
HttpResponse response = HttpContext.Current.Response; response.ContentEncoding = System.Text.Encodi ...
- 最近在学习Flask框架,那么就说下jinja2吧~~~
jinja是组成Flask的模板引擎,先写一个demo吧 {% block body %} <ul> {% for user in users %} <li><a hre ...
- ubuntu16.04运行ros的时候编译工作空间catkin_make出现的一个问题Could not find a package configuration file provided by
最近在进行ros里面的gazebo仿真之前需要对自己创建的工作空间进行编译,但是进行编译的时候输入catkin_make出现如下错误提示 查阅ROS问答社区之后发现两个比较有用的链接,如下 https ...
- Swing学习2——图标添加Icon接口使用
废话没有,看代码. 主要就是通过实现Icon接口在标签添加一个圆形图标,并在框架中显示. package com.sword.swing_test; import javax.swing.*; imp ...
- NHibernate4使用Oracle.ManagedDataAccess.dll连接oracle及配置多个数据库连接
NHibernate数据库配置参数在hibernate.cfg.xml中 <?xml version="1.0" encoding="utf-8"?> ...
- 利用隐藏 iframe 下载文件
在开发项目中遇到问题:下载文件后台报错,下载文件的页面会出现空白或异常信息,需要解决. 解决方法:利用隐藏iframe下载文件 3:对于a标签,采用target属性方法 <a target=&q ...
- BT详解
bittorrent是一个文件分发协议,它使用url来定位文件而且跟web服务无缝集成.当有多个人同时下载同一个文件时,下载者之间可以互相上传自己已有的那部分文件,让一个文件支持很多人同时下载却只增加 ...
- 面试知识点准备-C++常见问题
博客园写写格式简单的文章还行,格式一复杂就不行了,可能是我不会用吧,我有强迫症,有道云格式很好用,以后去有道写这种东西了 有道云笔记链接:http://note.youdao.com/noteshar ...
- iptables 添加raw提高服务器性能之路
前几天准备把线上一批机器添加iptables.于是梳理出几个需要通外网的端口,80,81等. 防火墙规则如下: #### filter table ########################## ...