本文实例为大家分享了android九宫格图片展示的具体代码,供大家参考,具体内容如下
当滚动条滚动到内容区域的时候,侧边导航条定位到屏幕,不再动,并且点击导航条跳转到内容所在的位置;
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <style> *{ padding: 0; margin: 0; } .left{ float: left; padding: 0 0 328px 0; } .left div{ width: 800px; height: 300px; line-height: 300px; text-align: center; font-size: 30px; background: gray; margin: 10px 0; } .nav{ position: absolute; right:20px; top: 20px; } .nav div{ width: 100px; height: 80px; line-height: 80px; text-align: center; background: pink; margin: 10px 0; cursor: pointer; } .bottom{ overflow: hidden; width: 100%; position: relative; } </style> <title>document</title> </head> <body> <img style="width:100%" src="o_1bsmo1kpn1hp61bm0176i1bk618uo9.jpg" alt=""> <div class="bottom"> <div class="left"> <div class="one leftdiv" id="one"> 一 </div> <div class="conone leftdiv" id="two"> 二 </div> <div class="leftdiv" id="three "> 三 </div> <div class="leftdiv" id="four"> 四 </div> </div> <div class="nav"> <div class="one navdiv">one</div> <div class="two navdiv">two</div> <div class="three navdiv">three</div> <div class="four navdiv">four</div> </div> </div> <script src="jquery.js"></script> <script> $(window).scroll(function(e){ console.log($(window).scrolltop()); if ($(window).scrolltop() >$('#one').offset().top) { $('.nav').css({'position':'fixed'}); console.log('ss'); } else{ $('.nav').css({'position':'absolute'}); } }) $('.nav div').click(function(){ var i = $('.navdiv').index(this); var x = $('.leftdiv').eq(i).offset().top; $('html, body').animate({scrolltop:x+'px'},500); }) </script> </body> </html>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
您可能感兴趣的文章:
- vue init初始化项目后 npm run dev报错 10% building modules 1/1 modules 0 activeevents
- axios 处理 302 状态码的解决方法
- [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/feature
- react-native 在新版Xcode(10+)中运行出现的问题: node_modules/react-native/third-party/glog-0.3.4 , C compiler cannot create executables
- 使用puppeteer爬取网站并抓出404无效链接
- 【angular2+typeScript+ng-zorro】Carousel 走马灯的左右方向控件实现
- VUE +element el-table运用sortable 拖拽table排序,实现行排序,列排序
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论