HTML页面滚动时部分内容位置固定不滚动的实现 <!DOCTYPE html> <html> <head> <meta charset=”UTF-8″> <title>无标题页</title> </head> <body style=”width: 900px; margin: 0px auto; line-height: 23px; padding: 10px;”> <div> <div style=”float: left; width: 120px;”> <div> 我会滚动<br/> 滚动内容区域<br/> 滚动内容区域<br/> 滚动内容区域<br/> </div> <div id=”div1″ style=”border: solid 1px gray; width: 90px; padding: 10px; background-color: #eff;”> 我不滚动<br/> 你看我<br/><br/> 我不滚动<br/> 你看我<br/><br/> 我不滚动<br/> 你看我<br/><br/> 我不滚动<br/> 你看我<br/><br/> </div> </div> <div style=”float: right; width: 750px; border: solid 1px gray; padding: 10px;”> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssss我是内容ssss</span><br> <span>ssssssssssssssss</span><br> <span>sssssss我是内容sssssssss</span><br> <span>ssssssssssssssss</span><br> <span>sssssss我是内容sssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br><span>ssssss我是内容ssssssssss</span><br> <span>ssssssssssssssss</span><br> <span>ssssssssssssssss</span><br> </div> </div> <script type=”text/javascript”> function htmlScroll() { var top = document.body.scrollTop || document.documentElement.scrollTop; if (elFix.data_top < top) { elFix.style.position = ‘fixed’; elFix.style.top = 0; elFix.style.left = elFix.data_left; } else { elFix.style.position = ‘static’; } } function htmlPosition(obj) { var o = obj; var t = o.offsetTop; var l = o.offsetLeft; while (o = o.offsetParent) { t += o.offsetTop; l += o.offsetLeft; } obj.data_top = t; obj.data_left = l; } var oldHtmlWidth = document.documentElement.offsetWidth; window.onresize = function () { var newHtmlWidth = document.documentElement.offsetWidth; if (oldHtmlWidth == newHtmlWidth) { return; } oldHtmlWidth = newHtmlWidth; elFix.style.position = ‘static’; htmlPosition(elFix); htmlScroll(); } window.onscroll = htmlScroll; var elFix = document.getElementById(‘div1’); htmlPosition(elFix); </script> </body> </html>
2024最新激活全家桶教程,稳定运行到2099年,请移步至置顶文章:https://sigusoft.com/99576.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。 文章由激活谷谷主-小谷整理,转载请注明出处:https://sigusoft.com/86289.html