您的位置:首页 > 其它

两个div滚动条同步简单实现

2015-05-26 15:31 225 查看
横向滚动条同步:

<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  滚动条