div同步滚动js

来源:互联网 发布:ug8.0编程手机教程 编辑:程序博客网 时间:2024/06/10 07:39
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><meta content="max-age=0" http-equiv="Cache-Control"><meta content="YES" name="apple-touch-fullscreen"><meta content="yes" name="apple-mobile-web-app-capable"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"></head><body><div id="div1" style="width:200px;height:200px; background: blue; border:1px #ddd solid; overflow:auto;"  onscroll="document.getElementById('div2').scrollLeft = this.scrollLeft;document.getElementById('div3').scrollTop = this.scrollTop;"><div style="width:800px; height:800px;">111111111111111111111111111111111111111111111111111111dsdsdsddadasd23232323232<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/>2<br/></div></div><div id="div2" style="width:200px; border:1px #ddd solid;background: red; overflow:scroll;"  onscroll="document.getElementById('div1').scrollLeft = this.scrollLeft;"><div style="width:800px; height:50px;">1234564d65sds5dad起嗯无群二wq9e8eqw89e789we89qwe98wq74e9q8we89wq98qwe98qe98qw而且去问问去</div></div><div id="div3" style="width:200px;background: yellow;  border:1px #ddd solid;height:200px; overflow:scroll;" onscroll="document.getElementById('div1').scrollTop = this.scrollTop;" ><div style="width:50px; height:800px;">3<br/>3<br/>3<br/>3<br/>3<br/>3<br/>3<br/>3<br/>3<br/>3<br/></div></div></body></html>