温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

固定table表头

发布时间:2020-07-17 03:22:06 来源:网络 阅读:489 作者:laiwenhuajava 栏目:开发技术

项目中设计的报表table设计的列数相对过多,当拖动下方的滚动条时无法对应表头所对应的列,因此在网上搜索了好一段日子,最后在网上找到了一些参考资料,然后总结归纳出兼容行列合并的固定表头demo。

多浏览器没有做太多测试,但是在ie9、火狐、360浏览器中已测试通过。 




<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>固定table表头</title>


<style type="text/css">

.div1All{

position: absolute; 

left: 0px; 

right: 0px; 

top: 0px; 

bottom: 0px

}

.divHeaderID{

margin-right: auto; 

margin-left: auto; 

overflow: hidden;

bgcolor: blue;

}

.divContentID{

position: absolute; 

left: 0px; 

top: 30.5px; 

bottom: 0px; 

right: 0px; 

overflow: scroll

}

</style>


</head>

<body>

<div class="div1All">

<div class="divHeaderID">

<table border="1" cellspacing="0">

<Tr >

<Th width="100px">Header A</Th>

<Th width="100px">Header B</Th>

<Th width="100px">Header C</Th>

<Th width="100px">Header D</Th>

<Th width="100px">Header E</Th>

<Th width="100px">Header F</Th>

</Tr>

</table>

</div>

<div class="divContentID">

<table border="1" cellspacing="0" >

<c:forEach begin="1" end="100" varStatus="index"> 

<Tr>

<Td width="100px">${index.index}</Td>

<Td width="100px">B</Td>

<Td width="100px">C</Td>

<Td width="100px">D</Td>

<Td width="100px">E</Td>

<Td width="100px">F</Td>

</Tr> 

</c:forEach>

</table>

</div>

</div>

</body>

</html> 


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI