横向滚动条同步:
<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>
本文详细介绍了如何实现网页中两个div元素的滚动条同步,包括横向滚动条同步与竖向滚动条同步的代码实现及原理解析。
334

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



