国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

基于jQuery實現定位導航位置效果

2019-11-19 14:56:00
字體:
來源:轉載
供稿:網友

本文實例為大家分享了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>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 五家渠市| 互助| 灵山县| 余庆县| 绥江县| 夹江县| 西和县| 阿合奇县| 犍为县| 东平县| 兴宁市| 临高县| 乐都县| 昭平县| 遂平县| 太仆寺旗| 手游| 依安县| 武鸣县| 济阳县| 望谟县| 廊坊市| 民乐县| 永川市| 将乐县| 长沙市| 佛坪县| 正镶白旗| 永丰县| 泽州县| 沈阳市| 行唐县| 应城市| 宜良县| 鄂伦春自治旗| 台北县| 珠海市| 肇庆市| 定州市| 赤峰市| 西昌市|