国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁 - 科技 - 知識(shí)百科 - 正文

js實(shí)現(xiàn)導(dǎo)航跟隨效果

來源:懂視網(wǎng) 責(zé)編:小OO 時(shí)間:2020-11-27 22:03:44
文檔

js實(shí)現(xiàn)導(dǎo)航跟隨效果

本文實(shí)例為大家分享了js實(shí)現(xiàn)導(dǎo)航跟隨效果展示的具體代碼,供大家參考,具體內(nèi)容如下: 。如何實(shí)現(xiàn)上面的效果,請(qǐng)看下面的步驟。第一步:用 css 調(diào)整樣式 ,這里小編用的是彈性盒子實(shí)現(xiàn)導(dǎo)航的平均分配。(聰明的你可以嘗試用其他的方式看看能不能實(shí)現(xiàn))css代碼如下:
推薦度:
導(dǎo)讀本文實(shí)例為大家分享了js實(shí)現(xiàn)導(dǎo)航跟隨效果展示的具體代碼,供大家參考,具體內(nèi)容如下: 。如何實(shí)現(xiàn)上面的效果,請(qǐng)看下面的步驟。第一步:用 css 調(diào)整樣式 ,這里小編用的是彈性盒子實(shí)現(xiàn)導(dǎo)航的平均分配。(聰明的你可以嘗試用其他的方式看看能不能實(shí)現(xiàn))css代碼如下:

本文實(shí)例為大家分享了js實(shí)現(xiàn)導(dǎo)航跟隨效果展示的具體代碼,供大家參考,具體內(nèi)容如下

                          

如何實(shí)現(xiàn)上面的效果,請(qǐng)看下面的步驟

第一步:用 css 調(diào)整樣式 ,這里小編用的是彈性盒子實(shí)現(xiàn)導(dǎo)航的平均分配。(聰明的你可以嘗試用其他的方式看看能不能實(shí)現(xiàn))css代碼如下:

<style type="text/css">
 *{padding:0;margin:0;}
 a{text-decoration:none;}
 html,body{height:100%;width:100%;background:black;}
 ul{position:relative;width:990px;list-style:none;background:white;display: flex;flex-direction:row;justify-content: space-around;margin:50px auto;border-radius:10px;}
 ul li{position: relative;flex:1;text-align:center;}
 ul li a{font-size:18px;color:#333;padding:10px 0;display: block;}
 .cloud{position:absolute;left:32px;top:0;bottom:0;margin:auto;width:83px;height:42px;background:url('images/cloud.gif');}
 </style>

html代碼如下:這里 a 標(biāo)簽中的 href 屬性后面加上那句代碼是為了在實(shí)現(xiàn)點(diǎn)擊事件時(shí)不讓他有其他事件發(fā)生

<ul>
 <span class="cloud"></span>
 <li> <a href="javascript:viod(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >首頁 </a></li>
 <li><a href="javascript:viod(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >電視劇</a></li>
 <li><a href="javascript:viod(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >最新電影</a></li>
 <li><a href="javascript:viod(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >新聞?lì)^條</a></li>
 <li><a href="javascript:viod(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >八卦娛樂</a></li>
 <li><a href="javascript:viod(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >軍事熱點(diǎn)</a></li>
 </ul>

第二步:分析下如何獲得   圖片(cloud.gif)   距離最左邊的  left  值

 第三步:實(shí)現(xiàn)鼠標(biāo)移動(dòng),移除,和點(diǎn)擊事件的效果

 <script type="text/javascript">
 //獲得類為cloud的標(biāo)簽,
 var pic=document.getElementsByClassName('cloud')[0];
 //獲得所有的 li 標(biāo)簽
 var liList=document.getElementsByTagName('li');
 //定義向右的移動(dòng)初始距離
 var liLeft=32;
 //定義緩慢動(dòng)畫的初始值
 var header=32;
 //用于定義當(dāng)鼠標(biāo)點(diǎn)擊時(shí)的初始位置
 var currentLeft=32;
 for(var i=0;i<liList.length;i++){
 //鼠標(biāo)放上事件
 liList[i].onmouseover=function(){
 //獲取目標(biāo)距離
 liLeft = this.offsetLeft+this.offsetWidth/2-pic.offsetWidth/2;
 }
 //鼠標(biāo)移除事件
 liList[i].onmouseout=function(){
 //當(dāng)鼠標(biāo)移除某個(gè)li的時(shí)候把目標(biāo)距離改為初始狀態(tài)
 liLeft=currentLeft;
 }
 //鼠標(biāo)點(diǎn)擊事件
 liList[i].onclick=function(){
 currentLeft=this.offsetLeft+this.offsetWidth/2-pic.offsetWidth/2;
 }
 
 }
 //定義緩慢動(dòng)畫
 setInterval(function(){
 header = header + (liLeft-header)/10;
 pic.style.left = header + 'px';
 },20);
 </script>

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

js實(shí)現(xiàn)導(dǎo)航跟隨效果

本文實(shí)例為大家分享了js實(shí)現(xiàn)導(dǎo)航跟隨效果展示的具體代碼,供大家參考,具體內(nèi)容如下: 。如何實(shí)現(xiàn)上面的效果,請(qǐng)看下面的步驟。第一步:用 css 調(diào)整樣式 ,這里小編用的是彈性盒子實(shí)現(xiàn)導(dǎo)航的平均分配。(聰明的你可以嘗試用其他的方式看看能不能實(shí)現(xiàn))css代碼如下:
推薦度:
  • 熱門焦點(diǎn)

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 一区二区免费播放 | 在线综合亚洲欧美自拍 | 91精品国产综合久久久久久 | 亚洲国产成人久久一区二区三区 | 国产欧美视频在线观看 | 欧美日韩国产综合视频在线看 | 国产va在线视频观看 | 欧美精品一区二区三区在线 | 最新国产精品亚洲 | 久久一卡二卡 | 国产精品久久久久国产精品 | 91久久精品国产性色也91久久 | 国产在线视频专区 | 国内精品伊人久久久久 | 日本一区二区三区在线播放 | 国产精品第二页 | 国产精品一区二区久久精品 | 91久久综合九色综合欧美98 | 国产成人一区二区三区小说 | 五月婷婷网站 | 毛片1级 | 国产资源在线看 | 精品久久久久久综合日本 | 国产伦精品一区二区三区免 | 亚洲小说欧美激情另类 | 一区一精品 | 欧美亚洲另类在线观看 | 国产精选在线视频 | 精品国产不卡一区二区三区 | 国产精品综合一区二区 | 国产精品九九久久精品女同 | 欧美日韩国产高清 | 亚洲伊人久久大香线蕉综合图片 | 国内一区亚洲综合图区欧美 | 国产成人成人一区二区 | 亚洲精品日韩中文字幕久久久 | 国产一区在线观看视频 | 欧洲精品一区二区三区 | 国产女同一区二区三区五区 | 日韩欧美一区二区三区中文精品 | 亚洲欧美日韩精品专区卡通 |