javascript實(shí)現(xiàn)超炫的向上滑行菜單實(shí)例
本文實(shí)例講述了javascript實(shí)現(xiàn)超炫的向上滑行菜單。分享給大家供大家參考。具體如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>JS實(shí)現(xiàn)文字上下滑動(dòng)導(dǎo)航</title>
<style type="text/css">
body { margin:0; background:#66FF99; }
ul { padding-left:0; margin:0; }
li { list-style:none; }
#nav { height:40px; background:#900; margin-top:50px; }
#nav ul { width:240px; height:40px; margin:0 auto; }
#nav li {height:40px; width:240px;}
#nav a { float:left; width:240px;position:relative; height:40px; overflow:hidden; font-size:14px; color:#e0e03a; text-decoration:none; cursor:pointer; }
#nav strong { float:left;width:240px; }
#nav span { float:left;width:200px; padding:0 20px; height:40px; line-height:40px; background:#900; clear:both; white-space:nowrap;}
#nav .active,#nav .current span { background:#600; color:#fff; }
#nav .current .active { color:#e0e03a; }
</style>
<script>
window.onload=function()
{
var oDiv=document.getElementById('nav');
var aStrong=oDiv.getElementsByTagName('strong');
var aA=oDiv.getElementsByTagName('a');
var iTarget=oDiv.getElementsByTagName('li')[0].offsetHeight;
for(var i=0; i<aStrong.length; i++)
{
aA[i].style.width=aStrong[i].style.width=aStrong[i].getElementsByTagName('span')[0].offsetWidth+'px';
aStrong[i].style.position='absolute';
aStrong[i].style.top=aStrong[i].style.left=0;
aStrong[i].onmouseover=function()
{
startMove(this, -iTarget);
};
aStrong[i].onmouseout=function()
{
startMove(this, 0);
};
}
};
function startMove(obj,target)
{
clearInterval(obj.iTime);
obj.iTime=setInterval(function(){
if(obj.offsetTop==target)
{
clearInterval(obj.iTime);
}
else
{
var iSpeed=(target-obj.offsetTop)/4;
iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed);
obj.style.top=obj.offsetTop+iSpeed+'px';
}
}, 30);
}
</script>
</head>
<body>
<div id="nav">
<ul>
<li class="current">
<a href="#">
<strong>
<span>首頁(yè)</span>
<span class="active">首頁(yè)</span>
</strong>
</a>
</li>
<li>
<a href="#">
<strong>
<span>前端開(kāi)發(fā)課程</span>
<span class="active">前端開(kāi)發(fā)課程</span>
</strong>
</a>
</li>
<li>
<a href="#">
<strong>
<span>妙味視頻教程</span>
<span class="active">妙味視頻教程</span>
</strong>
</a>
</li>
<li>
<a href="#">
<strong>
<span>周末班上課安排</span>
<span class="active">周末班上課安排</span>
</strong>
</a>
</li>
<li>
<a href="#">
<strong>
<span>結(jié)課標(biāo)準(zhǔn)</span>
<span class="active">結(jié)課標(biāo)準(zhǔn)</span>
</strong>
</a>
</li>
<li>
<a href="#">
<strong>
<span>聯(lián)系妙味</span>
<span class="active">聯(lián)系妙味</span>
</strong>
</a>
</li>
</ul>
</div>
</body>
</html>
希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
- JavaScript+CSS實(shí)現(xiàn)仿天貓側(cè)邊網(wǎng)頁(yè)菜單效果
- CSS javascript 結(jié)合實(shí)現(xiàn)懸浮固定菜單效果
- Javascript仿新浪游戲頻道鼠標(biāo)懸停顯示子菜單效果
- javascript實(shí)現(xiàn)在下拉列表中顯示多級(jí)樹(shù)形菜單的方法
- Javascript實(shí)現(xiàn)鼠標(biāo)右鍵特色菜單
- javascript簡(jiǎn)單實(shí)現(xiàn)滑動(dòng)菜單效果的方法
- javascript實(shí)現(xiàn)樹(shù)形菜單的方法
- javascript實(shí)現(xiàn)控制的多級(jí)下拉菜單
- JavaScript實(shí)現(xiàn)級(jí)聯(lián)菜單的方法
- JavaScript實(shí)現(xiàn)向右伸出的多級(jí)網(wǎng)頁(yè)菜單效果
相關(guān)文章
微信小程序 數(shù)據(jù)綁定及運(yùn)算的簡(jiǎn)單實(shí)例
這篇文章主要介紹了微信小程序 數(shù)據(jù)綁定的簡(jiǎn)單實(shí)例的相關(guān)資料,希望通過(guò)本文能幫助到大家,需要的朋友可以參考下2017-09-09
gulp-font-spider實(shí)現(xiàn)中文字體包壓縮實(shí)踐
這篇文章主要為大家介紹了gulp-font-spider實(shí)現(xiàn)中文字體包壓縮實(shí)踐詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03
微信小程序 this和that詳解及簡(jiǎn)單實(shí)例
這篇文章主要介紹了微信小程序 this和that詳解及簡(jiǎn)單實(shí)例的相關(guān)資料,需要的朋友可以參考下2017-02-02
微信小程序 向左滑動(dòng)刪除功能的實(shí)現(xiàn)
這篇文章主要介紹了微信小程序 向左滑動(dòng)刪除功能的實(shí)現(xiàn)的相關(guān)資料,需要的朋友可以參考下2017-03-03
JavaScript中使用toLocaleString數(shù)字格式化處理詳解
這篇文章主要為大家介紹了JavaScript中使用toLocaleString數(shù)字格式化處理詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08
詳解如何發(fā)布TypeScript編寫(xiě)的npm包
這篇文章主要介紹了如何發(fā)布TypeScript編寫(xiě)的npm包實(shí)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-12-12
微信小程序 基礎(chǔ)組件與導(dǎo)航組件詳細(xì)介紹
這篇文章主要介紹了微信小程序 基礎(chǔ)組件與導(dǎo)航組件詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下2017-02-02
深入內(nèi)存原理談JS中變量存儲(chǔ)在堆中還是棧中
JavaScript中基本類(lèi)型存儲(chǔ)在堆中還是棧中,百度一下有很多不同的答案,本篇文章就來(lái)給大家為此做個(gè)詳細(xì)的介紹,需要的朋友可以參考一下2021-09-09

