<div class="table1-wapper">
<table width="100%" cellpadding="0" cellspacing="0" id="table1">
<tr><th><div>序号</div></th><th><div>股票名称</div></th>...</tr>
<tr>...</tr>
</table>
</div>
<div class="fixed-table1-wapper">
<table width="100%" cellpadding="0" cellspacing="0" id="fixed-table1">
</table>
</div>
var th_new=$("#table1 tr").eq(0).clone();
$("#fixed-table1").append(th_new);
function trResize(){
$("#fixed-table1 th").each(function(){
var num=$(this).index();
var th_width=$("#table1 th").eq(num).width();
$(this).css("width",th_width+"px");
});
}
$(".table1-wapper").scroll(function(){
var scroll=-$(this).scrollLeft()
$(".fixed-table1-wapper").css("left",scroll+"px");
});
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>表格整理</title>
<link rel="stylesheet" type="text/css" href="css/basic.css">
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<style type="text/css">
html{overflow:auto;}
.table-wapper{width:100%;margin:30px auto;font-size:16px;position:relative;overflow:hidden;}
.table1-wapper{height:200px;overflow-y:auto;}
.table-wapper table{border:1px solid #f00;line-height:2;border-collapse: collapse;white-space:nowrap;}
.table-wapper th{font-size:18px;font-weight:normal;background-color:#dbdbdb;}
.table-wapper td{text-align:center;border:1px solid #f00;}
.fixed-table1-wapper{position:absolute;top:0px;left:0px;background-color:#dbdbdb;}
/*#table1 tr:nth-child(2n){background-color:#ccc;}*/
</style>
</head>
<body >
<div class="table-wapper">
<div class="table1-wapper">
<table width="100%" cellpadding="0" cellspacing="0" id="table1">
<tr>
<th>序号</th>
<th>股票名称</th>
<th>股票代码</th>
<th>成交</th>
<th>涨跌幅</th>
<th>换手率</th>
<th>行业板块</th>
</tr>
<tr>
<td>1</td>
<td>光明乳业</td>
<td>600597</td>
<td>15.2</td>
<td>+6.23%</td>
<td>0.12%</td>
<td>食品饮料</td>
</tr>
<tr>
<td>2</td>
<td>光明乳业</td>
<td>600597</td>
<td>15.2</td>
<td>+6.23%</td>
<td>0.12%</td>
<td>食品饮料</td>
</tr>
<tr>
<td>3</td>
<td>光明乳业</td>
<td>600597</td>
<td>15.2</td>
<td>+6.23%</td>
<td>0.12%</td>
<td>食品饮料</td>
</tr>
<tr>
<td>4</td>
<td>光明乳业</td>
<td>600597</td>
<td>15.2</td>
<td>+6.23%</td>
<td>0.12%</td>
<td>食品饮料</td>
</tr>
<tr>
<td>5</td>
<td>光明乳业</td>
<td>600597</td>
<td>15.2</td>
<td>+6.23%</td>
<td>0.12%</td>
<td>食品饮料</td>
</tr>
<tr>
<td>6</td>
<td>光明乳业</td>
<td>600597</td>
<td>15.2</td>
<td>+6.23%</td>
<td>0.12%</td>
<td>食品饮料</td>
</tr>
<tr>
<td>7</td>
<td>光明乳业</td>
<td>600597</td>
<td>15.2</td>
<td>+6.23%</td>
<td>0.12%</td>
<td>食品饮料</td>
</tr>
<tr>
<td>8</td>
<td>光明乳业</td>
<td>600597</td>
<td>15.2</td>
<td>+6.23%</td>
<td>0.12%</td>
<td>食品饮料</td>
</tr>
<tr>
<td>9</td>
<td>光明乳业</td>
<td>600597</td>
<td>15.2</td>
<td>+6.23%</td>
<td>0.12%</td>
<td>食品饮料</td>
</tr>
<tr>
<td>10</td>
<td>光明乳业</td>
<td>600597</td>
<td>15.2</td>
<td>+6.23%</td>
<td>0.12%</td>
<td>食品饮料</td>
</tr>
</table>
</div>
<div class="fixed-table1-wapper">
<table width="100%" cellpadding="0" cellspacing="0" id="fixed-table1">
</table>
</div>
</div>
<script type="text/javascript">
$(function(){<BR> $("#table1 tr:even").css("background-color","#ccc"); //奇偶行颜色
var inner_width=$("#table1").outerWidth();
$(".fixed-table1-wapper").css("width",inner_width+"px");
var th_new=$("#table1 tr").eq(0).clone();
$("#fixed-table1").append(th_new);
})
$(window).resize(function(){
trResize();
});
$(".table1-wapper").scroll(function(){
var scroll=-$(this).scrollLeft()
$(".fixed-table1-wapper").css("left",scroll+"px");
});
function trResize(){
var inner_width=$("#table1").outerWidth();
$(".fixed-table1-wapper").css("width",inner_width+"px");
$("#fixed-table1 th").each(function(){
var num=$(this).index();
var th_width=$("#table1 th").eq(num).width();
//console.log("th_width:"+th_width);
$(this).css("width",th_width+"px");
});
}
</script>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有