横向滚动条同步:
<div id="div1" style="width:500px; overflow:scroll;" onscroll="document.getElementById('div2').scrollLeft = this.scrollLeft;">
<div style="width:800px; height:50px;"></div>
</div>
<div id="div2" style="width:500px; overflow:scroll;" onscroll="document.getElementById('div1').scrollLeft = this.scrollLeft;">
<div style="width:800px; height:50px;"></div>
</div>
<div id="div1" style="width:500px; overflow:scroll;" onscroll="document.getElementById('div2').scrollTop = this.scrollTop;">
<div style="width:800px; height:50px;"></div>
</div>
<div id="div2" style="width:500px; overflow:scroll;" onscroll="document.getElementById('div1').scrollTop = this.scrollTop;">
<div style="width:800px; height:50px;"></div>
</div>

本文介绍了一种实现网页中两个滚动条同步的技术方案。通过简单的HTML和JavaScript代码,实现了横向及竖向滚动条的同步效果,便于同时查看多个相关联的内容区域。
361

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



