三款css橫向二級菜單效果代碼(1/2)

來源:互聯網
上載者:User
 代碼如下 複製代碼

<!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 runat="server">
<title>網頁特效下拉式功能表</title>
<style type="text/css">
* {
padding:0;
margin:0;
}
body {
font-family:verdana, sans-serif;
font-size:small;
}
#navigation, #navigation li ul {
list-style-type:none;
}
#navigation {
margin:20px;
}
#navigation li {
float:left;
text-align:center;
position:relative;
}
#navigation li a:link, #navigation li a:visited {
display:block;
text-decoration:none;
color:#000;
width:120px;
height:40px;
line-height:40px;
border:1px solid #fff;
border-width:1px 1px 0 0;
background:#c5dbf2;
padding-left:10px;
}
#navigation li a:hover {
color:#fff;
background:#2687eb;
}
#navigation li ul li a:hover {
color:#fff;
background:#6b839c;
}
#navigation li ul {
display:none;
position:absolute;
top:40px;
left:0;
margin-top:1px;
width:120px;
}
#navigation li ul li ul {
display:none;
position:absolute;
top:0px;
left:130px;
margin-top:0;
margin-left:1px;
width:120px;
}
</style>
<script type="text/javascript">
function displaysubmenu(li) {
var submenu = li.getelementsbytagname("ul")[0];
submenu.style.display = "block";
}
function hidesubmenu(li) {
var submenu = li.getelementsbytagname("ul")[0];
submenu.style.display = "none";
}
</script>
</head>
<body>
<ul id="navigation">
<li onmouseo教程ver="displaysubmenu(this)" onmouseout="hidesubmenu(this)">
<a href="#">欄目1</a>
<ul>
<li><a href="#">欄目1->菜單1</a></li>
<li><a href="#">欄目1->菜單2</a></li>
<li><a href="#">欄目1->菜單3</a></li>
<li><a href="#">欄目1->菜單4</a></li>
</ul>
</li>
<li onmouseover="displaysubmenu(this)" onmouseout="hidesubmenu(this)">
<a href="#">欄目2</a>
<ul>
<li><a href="#">欄目2->菜單1</a></li>
<li><a href="#">欄目2->菜單2</a></li>
<li><a href="#">欄目2->菜單3</a></li>
<li><a href="#">欄目2->菜單4</a></li>
<li><a href="#">欄目2->菜單5</a></li>
</ul>
</li>
<li onmouseover="displaysubmenu(this)" onmouseout="hidesubmenu(this)">
<a href="#">欄目3</a>
<ul>
<li onmouseover="displaysubmenu(this)" onmouseout="hidesubmenu(this)">
<a href="#">欄目3->菜單1</a>
<ul>
<li><a href="#">菜單1->子功能表1</a></li>
<li><a href="#">菜單1->子功能表2</a></li>
<li><a href="#">菜單1->子功能表3</a></li>
<li><a href="#">菜單1->子功能表4</a></li>
</ul>
</li>
<li><a href="#">欄目3->菜單2</a></li>
<li onmouseover="displaysubmenu(this)" onmouseout="hidesubmenu(this)">
<a href="#">欄目3->菜單3</a>
<ul>
<li><a href="#">菜單3->子功能表1</a></li>
<li><a href="#">菜單3->子功能表2</a></li>
<li><a href="#">菜單3->子功能表3</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</body>
</html>

第二款相容主瀏覽器

 代碼如下 複製代碼

<!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=utf-8" />
<title>純css的下拉式功能表支援ie6ie7firefox</title>
<style type="text/css">
*{margin:0;padding:0;}
.menu{font-size:12px;position:relative;z-index:100;}
.menu li {float:left;position:relative;list-style:none;}
.menu ul ul {visibility:hidden;position:absolute;left:0px;top:32px;}
.menu table {position:absolute;top:0;left:0;}
.menu ul li:hover ul,
.menu ul a:hover ul{visibility:visible;}
.menu a{display:block;background:#0c3;color:#fff;text-decoration:none;height:32px;line-height:32px;width:100px;text-align:center;font-weight:bold;}
.menu a:hover{background:#fc0;color:#09c;}
.menu ul ul{}
.menu ul ul li {clear:both;text-align:left;}
.menu ul ul li a{display:block;width:100px;height:32px;margin:0;border:0;border-bottom:1px solid #390;}
.menu ul ul li a:hover{background:#fc0;}
</style>
</head>

<body>

<div class="menu">
<ul>
<li><a href="">menu1
<!--[if ie 7]><!--></a><!--<![endif]-->
<!--[if lte ie 6]><table><tr><td><![endif]-->
<ul>
<li><a href="">sub menu1.1</a></li>
<li><a href="">sub menu1.2</a></li>
</ul>
<!--[if lte ie 6]></td></tr></table></a><![endif]-->
</li>
<li><a href="">menu2
<!--[if ie 7]><!--></a><!--<![endif]-->
<!--[if lte ie 6]><table><tr><td><![endif]-->
<ul>
<li><a href="">sub menu2.1</a></li>
<li><a href="">sub menu2.2</a></li>
</ul>
<!--[if lte ie 6]></td></tr></table></a><![endif]-->
</li>
<li><a href="">menu3
<!--[if ie 7]><!--></a><!--<![endif]-->
<!--[if lte ie 6]><table><tr><td><![endif]-->
<ul>
<li><a href="">sub menu3.1</a></li>
<li><a href="">sub menu3.2</a></li>
</ul>
<!--[if lte ie 6]></td></tr></table></a><![endif]-->
</li>
<li><a href="">menu4</a></li>
</ul>
</div>

</body>
</html>


導覽功能表三

<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en"
"http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>二級橫向菜單</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript">
startlist = function() {
    if (document.all && document.getelementbyid) {
        navroot = document.getelementbyid("nav");
            for (i=0; i < navroot.childnodes.length; i++) {
                node = navroot.childnodes[i];
                if (node.nodename=="li") {
                    node.onmouseover=function() {
                    this.classname+=" over";
                }
                node.onmouseout=function() {
                    this.classname=this.classname.replace(" over", "");
                }
            }
        }
    }
}
window.onload = startlist;
</script>

 

 

首頁 1 2 末頁
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.