欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS+CSS實(shí)現(xiàn)鼠標(biāo)滑過時(shí)動(dòng)態(tài)翻滾的導(dǎo)航條效果

 更新時(shí)間:2015年09月24日 10:57:35   作者:企鵝  
這篇文章主要介紹了JS+CSS實(shí)現(xiàn)鼠標(biāo)滑過時(shí)動(dòng)態(tài)翻滾的導(dǎo)航條效果,涉及JavaScript動(dòng)態(tài)設(shè)置css樣式動(dòng)畫過度效果的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了JS+CSS實(shí)現(xiàn)鼠標(biāo)滑過時(shí)動(dòng)態(tài)翻滾的導(dǎo)航條效果。分享給大家供大家參考。具體如下:

這是一款鼠標(biāo)懸停時(shí)動(dòng)態(tài)翻滾的導(dǎo)航條,注意這里用了兩個(gè)背景圖,請(qǐng)等待網(wǎng)頁加載完成或多刷新幾次,這個(gè)是使用JavaScript實(shí)現(xiàn)的,不過代碼好像是從jQuery里摘出來的,有點(diǎn)像。

運(yùn)行效果截圖如下:

在線演示地址如下:

http://demo.jb51.net/js/2015/js-css-mouse-over-nav-scroll-style-codes/

具體代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>動(dòng)態(tài)翻滾的導(dǎo)航條</title>
<style type="text/css">
.clear:after{content:"."; display:block; height:0; clear:both; visibility:hidden}.clear{display:inline-block}.clear{display:block}
div#nav{height:32px; background:url(images/YL29.jpg) repeat-x}
div#nav ul{
  width:705px;
  list-style:none;
  margin-top: 0;
  margin-right: auto;
  margin-bottom: 0;
  margin-left: 0px;
}
div#nav ul li{
  float:left;
  height:32px;
  overflow:hidden;
  background-image: url(images/YL30.jpg);
  background-repeat: repeat-y;
  background-position: right 0;
  padding-top: 0;
  padding-right: 1px;
  padding-bottom: 0;
  padding-left: 0px;
  font-family: Arial;
  font-size: 12px;
  line-height: 32px;
  font-weight: bold;
}
div#nav ul li a{
  float:left;
  height:100%;
  width: 77px;
  background:url(images/YL28.jpg) repeat-x;
  color:#fff;
  text-decoration:none;
  padding-top: 0;
  padding-right: 5px;
  padding-bottom: 0;
  padding-left: 5px;
  text-align:center;
}
div#nav ul li a.hover{
  clear:both;
  background-position:0 -32px;
  width: 77px;
}
div#nav ul li.on a{
  background-position:0 -32px;
}
div#nav ul li.nobg{background:none}
/* ]]> */
</style>
</head>
<body>
<div id="nav">
<ul class="clear">
<li><a href="#">腳本之家</a></li>
<li><a href="#">網(wǎng)頁特效</a></li>
<li><a href="#">工具軟件</a></li>
<li><a href="#">腳本下載</a></li>
<li><a href="#">菜單導(dǎo)航</a></li>
<li><a href="#">層和布局</a></li>
<li><a href="#">論壇社區(qū)</a></li>
<li><a href="#">廣告聯(lián)系</a></li>
<li class="nobg"></li>
</ul>
</div>
<script type="text/javascript"> 
/* <![CDATA[ */
function nav(c, config){
  this.config = config || {speed: 10, num: 2};
  this.container = (typeof(c)=="object") ? c : document.getElementById(c);
  this.lineHeight = this.container.offsetHeight;
  this.scrollTimeId = null;
  var _this = this;  
  this.__construct = function (){
    var inner,el,href;
    inner = _this.container.childNodes[0].innerHTML;
    href = _this.container.childNodes[0].href;
    el = document.createElement("a");
    el.innerHTML = inner;
    el.href = href;
    el.className = 'hover';
    _this.container.appendChild(el);
    _this.container.onmouseover = function (){_this.start()};
    _this.container.onmouseout = function (){_this.end()};
  }();
  this.start = function (){
    _this.clear();
    _this.scrollTimeId = setTimeout(function(){_this.scrollUp();}, _this.config.speed);
  };
  this.end = function (){
    _this.clear();
    _this.scrollTimeId = setTimeout(function(){_this.scrollDown();}, _this.config.speed);
  };
  this.scrollUp = function (){
    var c = _this.container;  
    if(c.scrollTop >= _this.lineHeight){c.scrollTop = _this.lineHeight;return;}
    c.scrollTop += _this.config.num;
    _this.scrollTimeId = setTimeout(function(){_this.scrollUp();}, _this.config.speed);
  };
  this.scrollDown = function (){
    var c = _this.container;
    
    if(c.scrollTop <= 0){c.scrollTop = 0;return;}
    c.scrollTop -= _this.config.num;
    _this.scrollTimeId = setTimeout(function(){_this.scrollDown();}, _this.config.speed);
  };
  this.clear = function (){clearTimeout(_this.scrollTimeId)};
}
(function(){
  var container = document.getElementById('nav');
  var el_li = container.getElementsByTagName('li');
  var arr = [];
  for( var i = 0; i < el_li.length; i++){
    if(el_li[i].className == 'on') continue;
    arr[i] = new nav(el_li[i], {speed: 10, num: 4});
  }
})
();
/* ]]> */
</script>
</body>
</html>

希望本文所述對(duì)大家的JavaScript程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • 微信小程序?qū)崿F(xiàn)多選刪除列表數(shù)據(jù)功能示例

    微信小程序?qū)崿F(xiàn)多選刪除列表數(shù)據(jù)功能示例

    這篇文章主要介紹了微信小程序?qū)崿F(xiàn)多選刪除列表數(shù)據(jù)功能,涉及微信小程序列表數(shù)據(jù)讀取、顯示、刪除等相關(guān)操作技巧,需要的朋友可以參考下
    2019-01-01
  • JS利用時(shí)間戳倒計(jì)時(shí)的實(shí)現(xiàn)示例

    JS利用時(shí)間戳倒計(jì)時(shí)的實(shí)現(xiàn)示例

    這篇文章主要介紹了JS利用時(shí)間戳倒計(jì)時(shí)的實(shí)現(xiàn)示例,本文將提供代碼示例和詳細(xì)的步驟,幫助你實(shí)現(xiàn)一個(gè)簡單而實(shí)用的時(shí)間戳倒計(jì)時(shí),感興趣的可以了解一下
    2023-12-12
  • JavaScript?ES6模塊導(dǎo)入和導(dǎo)出的方法

    JavaScript?ES6模塊導(dǎo)入和導(dǎo)出的方法

    ES6在語言標(biāo)準(zhǔn)的層面上實(shí)現(xiàn)了模塊功能,而且實(shí)現(xiàn)的相當(dāng)簡單,完全可以取代CommonJS和AMD規(guī)范,成為瀏覽器和服務(wù)器通用的模塊解決方案,下面這篇文章主要給大家介紹了關(guān)于ES6模塊導(dǎo)入和導(dǎo)出的方法,需要的朋友可以參考下
    2022-07-07
  • 一個(gè)精簡的JS DIV層tab切換代碼

    一個(gè)精簡的JS DIV層tab切換代碼

    下面的代碼是比較精簡的js tab切換代碼,原理也比較簡單。
    2010-03-03
  • layer.js open 隱藏滾動(dòng)條的例子

    layer.js open 隱藏滾動(dòng)條的例子

    今天小編就為大家分享一篇layer.js open 隱藏滾動(dòng)條的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。 一起跟隨小編過來看看吧
    2019-09-09
  • 使用開源工具制作網(wǎng)頁驗(yàn)證碼的方法

    使用開源工具制作網(wǎng)頁驗(yàn)證碼的方法

    這篇文章主要介紹了使用開源工具制作網(wǎng)頁驗(yàn)證碼的方法的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2016-10-10
  • JS實(shí)現(xiàn)消滅星星小游戲

    JS實(shí)現(xiàn)消滅星星小游戲

    這篇文章主要為大家詳細(xì)介紹了JS實(shí)現(xiàn)消滅星星小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • echarts學(xué)習(xí)之如何給餅圖中間添加文字

    echarts學(xué)習(xí)之如何給餅圖中間添加文字

    這篇文章主要介紹了echarts學(xué)習(xí)之如何給餅圖中間添加文字問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-03-03
  • 微信小程序?qū)崿F(xiàn)登錄頁面

    微信小程序?qū)崿F(xiàn)登錄頁面

    這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)登錄頁面,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • js動(dòng)態(tài)生成form 并用ajax方式提交的實(shí)現(xiàn)方法

    js動(dòng)態(tài)生成form 并用ajax方式提交的實(shí)現(xiàn)方法

    下面小編就為大家?guī)硪黄猨s動(dòng)態(tài)生成form 并用ajax方式提交的實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-09-09

最新評(píng)論