css:样式
#divTitle{padding:10px;position:relative;top:0px;93.5%; z-index:100; background-color:#6FA1D8;}
<div id="divTitle" style=" display:none;">
<table style=" 100%; border-collapse: collapse;">
<tr style="background-color: #6fa1d8; height: 24px;">
<td style="130px;">功能分类名称</td>
<td style="160px;">项目名称</td>
<td style="130px;">初始金额</td>
<td style="130px;">待审核金额</td>
<td style="90px;">可用金额</td>
<td style="90px;">实际发生金额</td>
<td style="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');
}