日期:2014-05-16 浏览次数:20839 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
*{
margin:0;
padding:0;
}
div.tableContainer {
clear: both;
border: 0px solid #963;
height: 420px; /* html>body tbody.scrollContent height plus 23px for the header */
overflow: auto;
width: 756px /* Remember to leave 16px for the scrollbar! */
}
/* define width of table. IE browsers only */
div.tableContainer table {
float: left;
width: 740px;
border-collapse:collapse;
border: 1px solid #76a0ae;
background-color: #ddd2e5;
}
div.tableContainer table tr{
height:33px;
}
/*html>body */
tbody.scrollContent {
margin-top:10px;
display: block;
height: 352px;
overflow: auto;
width: 100%;
background-color: #eeeeee;
}
tbody td {
height: 32px;
}
/*html>body */
thead.fixedHeader tr {
display: block;
background-color: #ddd2e5;
}
/*html>body */
thead.fixedHeader th { /* TH 1 */
border: 1px solid #76a0ae;
width: 180px;
height:40px;
}
/*html>body */
thead.fixedHeader th + th { /* TH 2 */
width: 240px;
}
/*html>body */
thead.fixedHeader th + th + th { /* TH 3 +16px for scrollbar */
width: 336px;
}
/*html>body */
tbody.scrollContent td { /* TD 1 */
border: 1px solid #76a0ae;
width: 180px;
height:33px;
}
/*html>body */
tbody.scrollContent td + td { /* TD 2 */
width: 240px;
}
/*html>body */
tbody.scrollContent td + td + td { /* TD 3 +16px for scrollbar */
width: 320px;
}
</style>
</head>
<body>
<h1>Pure CSS Scrollable Table with Fixed Header</h1>
<p>Using CSS to allow