<style>
.drag{
overflow:visible;
width:2000px
}
.drag.index{
width:200px;
color:red;
position:absolute;
}
.drag span{
width:200px;
position:relative;
}
</style>
<script>
function scro(){
var index=document.getElementById("dv").firstChild;
index.style.left=parseInt(document.body.scrollLeft);
}
</script>
<body onscroll="scro()">
<div class="drag" id="dv" >
<span class="index" style="left:0">序号</span> <span>其他</span> <span>其他</span> <span>其他</span> <span>其他</span> <span>其他</span> <span>其他</span> <span>其他</span> <span>其他</span>
</div>
</body>
这个主要是别人给说的。然后自己根据意思改造了。
本文介绍了一种通过JavaScript实现的网页元素定位方法,并确保该元素在页面滚动时能够同步移动,保持相对位置不变。此技术适用于需要固定导航或其他需要跟随滚动条移动的场景。
1873

被折叠的 条评论
为什么被折叠?



