DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> CSS入門知識 >> CSS詳解 >> 當鼠標經過表格數據行時顏色不同且奇偶行顏色也不同
當鼠標經過表格數據行時顏色不同且奇偶行顏色也不同
編輯: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" />
<title>table 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;
}

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved