lt;!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>導航菜單</title>
<link rel="stylesheet" type="text/css" href="css/nav.css"/>
</head>
<body>
<!--頭部-->
<header>
<div class="container">
<!--導航條-->
<ul class="nav">
<li style="background-color: gold;">
<a href="#">首頁</a>
</li>
<li>
<a href="#">公司概況</a>
<ul class="nav-list">
<li>公司簡介</li>
<li>發展歷程</li>
<li>組織機構</li>
<li>總經理寄語</li>
</ul>
</li>
<li>
<a href="#">公司文化</a>
<ul class="nav-list">
<li>文化理念</li>
<li>員工活動</li>
<li>黨/工/團建設</li>
</ul>
</li>
<li>
<a href="#">公司新聞</a>
</li>
<li>
<a href="#">服務內容</a>
</li>
<li>
<a href="#">法律政策</a>
</li>
<li>
<a href="#">人才招聘</a>
</li>
<li>
<a href="#">聯系我們</a>
</li>
</ul>
</div>
</header>
</body>
</html>
@charset "utf-8";
*{
margin: 0px;
padding: 0px;
}
#goTopBtn, #goBottom, #shangy, #xiay, #menuPage, #lPage, #fPage{
width: 18px;
line-height: 1.2;
padding: 5px 0;
font-size: 12px;
text-align: center;
position: fixed;
right: 10px;
cursor: pointer;
filter: Alpha(opacity=30);
opacity=.3;
font-weight:bold;
}
#goTopBtn, #goBottom, #menuPage, #lPage, #fPage{
background-color:#999;
color:#000;
}
#shangy, #xiay, #lPage, #fPage{
background-color: #bbb;
color: #000;
}
#fPage{
bottom: 236px;
height:42px;
white-space:nowrap;
overflow:hidden;
//writing-mode:tb-rl;
}
#menuPage{
bottom: 198px;
height:27px;
white-space:nowrap;
overflow:hidden;
}
#lPage{
bottom: 145px;
height:42px;
white-space:nowrap;
overflow:hidden;
}
#goTopBtn{
bottom: 105px;
}
#goBottom {
bottom: 30px;
}
#shangy {
bottom: 80px;
}
#xiay {
bottom: 55px;
}
#goTopBtn:hover, #goBottom:hover, #shangy:hover, #xiay:hover, #menuPage:hover, #lPage:hover, #fPage:hover{
background-color:#ccc;
border:#ccc 0px solid;
}
#goTopBtn a:link, #goBottom a:link, #xiay a:link, #shangy a:link, #menuPage a:link, #menuPage a:visited, #lPage a:link, #fPage a:link, #lPage a:visited, #fPage a:visited {
text-decoration: none;
color:white;
}
<div id="fPage"><a id="fPagea" href="javascript:void(null)" target="_self">上<br />一<br />頁</a></div>
<div id="menuPage"><a href="index.html" target="_self">目<br />錄</a></div>
<div id="lPage"><a id="LPagea" href="javascript:void(null)" target="_self">下<br />一<br />頁</a></div>
<div style="display:none" id="goTopBtn"><a target="_self" style="color:#fff;">∧</a></div>
<div style="display:none" id="shangy">
<a onclick="shangy()" target="_self" style="color:#fff;">↑</a></div>
<div id="xiay">
<a onclick="xiay()" target="_self" style="color:#fff;">↓</a></div>
<div id="goBottom">
<a onclick="downn()" target="_self" style="color:#fff;">∨</a></div>
<script type=text/javascript>
goTopEx();
function xiay(){
window.scrollBy(0,window.innerHeight-10);
}
function shangy(){
window.scrollBy(0,-window.innerHeight+10);
}
var obj3=document.getElementById("xiay");
var obj4=document.getElementById("goBottom");
function getHeight(){
if(browser4=="ch"){
//谷歌瀏覽器
return document.body.clientHeight;
}else{
//IE、firefox等瀏覽器
return document.documentElement.clientHeight;
}
}
getHeight()<window.innerHeight+50?obj3.style.display="none":obj3.style.display="";
getHeight()<window.innerHeight+50?obj4.style.display="none":obj4.style.display="";
if(browser4!="ch"){//firefox需要嘗一下才顯示向下圖標
xiay();
shangy();
}
//上一頁、下一頁按鈕,需要文件名是數字
var strUrl=window.location.href;
var arrUrl=strUrl.split("/");
var thispage=arrUrl[arrUrl.length-1];
var thispage2=thispage.split(".");
var thispage3=thispage2[thispage2.length-2];
if(thispage3 == 1){
var obj5=document.getElementById("fPage");
obj5.style.display="none"
}else{
var fpage = thispage3 - 1;
fpage = fpage +".html"
document.getElementById("fPagea").href=fpage;
}
if(thispage3 == 100){
var obj6=document.getElementById("lPage");
obj6.style.display="none"
}else{
var fpage = thispage3 - 1;
fpage = fpage +".html"
document.getElementById("fPagea").href=fpage;
}
</script>
當將鼠標停留在“上一面”按鈕處時,網頁效果如下:
-End-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>HTML+CSS 二級導航</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
ul,ol{
list-style: none;
}
a{
color: #000;
display: block;
width: 140px;
height: 40px;
text-align: center;
line-height: 40px;
text-decoration: none;
}
/* ******************************************* */
.nav{
width: 100%;
height: 40px;
background-color: skyblue;
}
.nav>ul{
width: 1200px;
height: 40px;
margin: 0 auto;
/* 這個背景色是方便大家伙看的 */
/* background-color: red; */
}
.nav>ul>li{
float: left;
width: 140px;
height: 40px;
/*讓ol(二級導航根據他進行定位 所以li進行相對定位)*/
position: relative;
}
.nav>ul>li>ol{
background-color: skyblue;
position: absolute;
left: 0;
top: 40px;
display: none;/*初始值隱藏*/
}
/* 懸浮的效果 */
a:hover{
color: #fff;
background-color: deepskyblue;
}
.nav>ul>li:hover>a{
color: #fff;
background-color: deepskyblue;
}
.nav>ul>li:hover>ol{
display: block;
}
</style>
</head>
<body>
<div class="nav">
<ul>
<li><a href="">首頁</a></li>
<li>
<a href="">法師</a>
<ol>
<li><a href="">妲己</a></li>
<li><a href="">甄姬</a></li>
<li><a href="">安琪拉</a></li>
<li><a href="">張良</a></li>
</ol>
</li>
<li><a href="">戰士</a></li>
<li>
<a href="">刺客</a>
<ol>
<li><a href="">荊軻</a></li>
<li><a href="">張飛</a></li>
<li><a href="">關羽</a></li>
<li><a href="">黃忠</a></li>
<li><a href="">馬超</a></li>
<li><a href="">趙云</a></li>
<li><a href="">許諸</a></li>
</ol>
</li>
<li><a href="">射手</a></li>
<li><a href="">坦克</a></li>
<li>
<a href="">輔助</a>
<ol>
<li><a href="">蔡文姬</a></li>
<li><a href="">鬼谷子</a></li>
<li><a href="">莊周</a></li>
</ol>
</li>
</ul>
</div>
<p>HTML+CSS 二級導航</p>
</body>
</html>
*請認真填寫需求信息,我們會在24小時內與您取得聯系。