感谢您的支持,我会继续努力的!
打开微信扫一扫,即可进行扫码打赏哦
点我查看本站打赏源码!
Powered by RUNCODEX.COM,学的不仅是技术,更是梦想!!!
<script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script>
<div class="table-container header">
<table border>
<thead>
<tr>
<th>
表头1
</th>
表头2
</tr>
</thead>
</table>
</div>
<div class="table-container body">
<td>
列1
</td>
列2
xxxxxxxxxx
var containerDom = $(".table-container.body");
if (containerDom && containerDom.length) {
var onScroll = function () {
var translate = "translate(-" + this.scrollLeft + "px,0px)";
$(".header table").css('transform', translate);
};
containerDom.on('scroll', onScroll);
}
table{
border-collapse: collapse;
width:300px;
.body table{
border-top: hidden;
.table-container {
overflow: auto;
max-height: 100px;
width: 200px;
.table-container.header {
overflow: hidden;