先说效果描述如图:涉及到数据保密的缘故所以数据弄掉了。效果为:整个grid数据会出现横向,竖向滚动条。其中所有的表头:操作,序号,测试1.。。。等等要素,不会随着竖向滚动条的滚动而发生下移动的变化。而“操作”,“序号”,“测试1”,“测试2”,“测试3”,“测试4”,“测试5”这几个列的要素则进行了横向固定,不会随横向滚动条的移动而移动。当横向滚动条向右边移动时,右边的要素往左边的移动部分会被左边的要素遮罩住。所以图里看到“测试6”,“测试7”直到“测试12”这几个title都被遮盖了,因为横向滚动条往右边移动了。
①把下面的css保存起来作为.css文件,然后在jsp页面进行引入
div#DivContainer
{
height:300px;overflow: auto; overflow-y: scorll;margin-top: -1px;
}
table.lock
{
border-collapse:collapse;
border-right:gray 1px solid;
border-bottom:gray 1px solid;
border-color: gray;
}
td.Locked /* TD标签水平与垂直方向锁住单元格, 不随鼠标或滚动条移动 */
{
z-index: 30; position: relative;
top: expression(parentNode.parentNode.parentNode.parentNode.scrollTop);
left: expression(parentNode.parentNode.parentNode.parentNode.scrollLeft);
background-color: #cccccc; text-align: center;
/*border-top: solid 0px gray; border-bottom: solid 1px gray; border-left: solid 0px gray; border-right: solid 1px gray; */
border-left:gray 1px solid;
border-top:gray 1px solid;
}
th.Locked /* TH标签水平与垂直方向锁住单元格, 不随鼠标或滚动条移动 */
{
z-index: 30; position: relative;
top: expression(parentNode.parentNode.parentNode.parentNode.scrollTop);
left: expression(parentNode.parentNode.parentNode.parentNode.scrollLeft);
background-color: #cccccc; text-align: center;
/*border-top: solid 0px gray; border-bottom: solid 1px gray; border-left: solid 0px gray; border-right: solid 1px gray; */
border-left:gray 1px solid;
border-top:gray 0px solid;
}
tr.TrLocked
{
z-index: 30; position: relative;
top: expression(parentNode.parentNode.parentNode.scrollTop);
/*left: expression(parentNode.parentNode.parentNode.scrollLeft);*/
background-color: #cccccc; text-align: center;
/*border-top: solid 0px gray; border-bottom: solid 1px gray; border-left: solid 0px gray; border-right: solid 1px gray; */
border-left:gray 1px solid;
border-top:gray 0px solid;
}
th.HLoc