您的位置:首页 > 其它

滚动条超出表格标题,表格标题固定

2016-02-29 13:33 204 查看
css:样式

#divTitle{padding:10px;position:relative;top:0px;width:93.5%; z-index:100; background-color:#6FA1D8;}

<div id="divTitle" style=" display:none;">
<table style="width: 100%; border-collapse: collapse;">
<tr style="background-color: #6fa1d8; height: 24px;">
<td style="width:130px;">功能分类名称</td>
<td style="width:160px;">项目名称</td>
<td style="width:130px;">初始金额</td>
<td style="width:130px;">待审核金额</td>
<td style="width:90px;">可用金额</td>
<td style="width:90px;">实际发生金额</td>
<td style="width:90px;">使用百分比列</td>
</tr>
</table>
</div>

js 脚本

function menuFixed(id) {
var obj = document.getElementById(id);
var _getHeight = obj.offsetTop;
window.onscroll = function() {
changePos(id, _getHeight);
}
}
function changePos(id, height) {
var obj = document.getElementById(id);
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
var height = $("#table_Collgrid").offset().top;
if (scrollTop+20 < height) {
obj.style.position = 'relative';
obj.style.display = "none";
} else {
obj.style.position = 'fixed';
obj.style.display = "";
}
}
window.onload = function() {
menuFixed('divTitle');
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: