用CSS实现自动下拉菜单的多种方法 css导航栏下拉菜单

一、横向下拉菜单

<!DOCTYPE htmlPUBliC "-//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" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-CN"/>
<title>横向下拉菜单</title>
<style type="text/css">
<!--
* {margin:0;padding:0;border:0;}
body {
font-family: arial, 宋体, serif;
font-size:12px;
}
#nav {
height: 24px; list-style-type:none; padding-left:200px;
line-height:24px;overflow:hidden;background:#999;
}
#nav a {
display: block; width: 80px; text-align:center;
}
#nav a:link {
color:#EEE; text-decoration:none;
}
#nav a:visited {
color:#EEE;text-decoration:none;
}
#nav a:hover {
color:#FFF;text-decoration:none;font-weight:bold;background:#CCC;
}
#nav li {
float: left; width: 80px;
}
#nav li ul {
line-height: 24px;
list-style-type: none;
text-align:left;
left: -999px;
width: 520px; //注意,这里一定要设置宽度;
position: absolute;
background:#CCC;
}
#nav li ul li{
float: left;width: 80px; //float就是子菜单横向的关键,可以继承父菜单而省略float
}
#nav li ul a{
display: block; width:65px;text-align:left;padding-left:15px;
}
#nav li ul a:link {
color:#F1F1F1; text-decoration:none;
}
#nav li ul a:visited {
color:#F1F1F1;text-decoration:none;
}
#nav li ul a:hover {
color:#FFF;text-decoration:none;font-weight:normal;background:#C00;
}
#nav li:hover ul {
left:25%;
}
#nav li.sfhover ul {
left:25%;
}
#content {
clear: left;
}
-->
</style>
<scripttype=text/javascript><!--//--><![CDATA[//><!--
function menuFix() {
var sfEls =document.getElementByIdx("nav").getElementsByTagName_r("li");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=(this.className.length>0? " ": "") +"sfhover";
}
sfEls[i].onMouseDown=function() {
this.className+=(this.className.length>0? " ": "") +"sfhover";
}
sfEls[i].onMouseUp=function() {
this.className+=(this.className.length>0? " ": "") +"sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp("(?|^)sfhover\b"),
"");
}
}
}
window.onload=menuFix;
//--><!]]></script>
</head>
<body>
<ul id="nav">
<li><ahref="#">菜单一</a>
<ul>
<li><ahref="#">菜单一</a></li>
<li><ahref="#">菜单一</a></li>
<li><ahref="#">菜单一</a></li>
<li><ahref="#">菜单一</a></li>
<li><ahref="#">菜单一</a></li>
<li><ahref="#">菜单一</a></li>
</ul>
</li>
<li><ahref="#">菜单二</a>
<ul>
<li><ahref="#">菜单二</a></li>
<li><ahref="#">菜单二</a></li>
<li><ahref="#">菜单二</a></li>
<li><ahref="#">菜单二</a></li>
<li><ahref="#">菜单二</a></li>
</ul>
</li>
<li><ahref="#">菜单三</a>
<ul>
<li><ahref="#">菜单三</a></li>
<li><ahref="#">菜单三</a></li>
<li><ahref="#">菜单三</a></li>
<li><ahref="#">菜单三</a></li>
<li><ahref="#">菜单三</a></li>
</ul>
</li>
<li><ahref="#">菜单四</a>
<ul>
<li><ahref="#">菜单四</a></li>
<li><ahref="#">菜单四</a></li>
<li><ahref="#">菜单四</a></li>
<li><ahref="#">菜单四</a></li>
<li><ahref="#">菜单四</a></li>
</ul>
</li>
<li><ahref="#">菜单五</a>
<ul>
用CSS实现自动下拉菜单的多种方法 css导航栏下拉菜单
<li><ahref="#">菜单五</a></li>
<li><ahref="#">菜单五</a></li>
<li><ahref="#">菜单五</a></li>
<li><ahref="#">菜单五</a></li>
<li><ahref="#">菜单五&l--t;/a></li>
</ul>
</li>
<li><ahref="#">菜单六</a>
<ul>
<li><ahref="#">菜单六</a></li>
<li><ahref="#">菜单六</a></li>
<li><ahref="#">菜单六</a></li>
<li><ahref="#">菜单六</a></li>
<li><ahref="#">菜单六</a></li>
</ul>
</li>
</ul>
</div>
</body>
</html>

二、CSS下拉导航菜单效果

<!DOCTYPE html PUBliC "-//W3C//DTDXHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<title>CSS下拉菜单演示</title>
<style type="text/css">
<!--
*{margin:0;padding:0;border:0;}
body {
font-family: arial, 宋体, serif;
font-size:12px;
}
#nav {
line-height: 24px; list-style-type: none; background:#666;
}
#nav a {
display: block; width: 80px; text-align:center;
}
#nav a:link {
color:#666; text-decoration:none;
}
#nav a:visited {
color:#666;text-decoration:none;
}
#nav a:hover {
color:#FFF;text-decoration:none;font-weight:bold;
}
#nav li {
float: left; width: 80px; background:#CCC;
}
#nav li a:hover{
background:#999;
}
#nav li ul {
line-height: 27px; list-style-type: none;text-align:left;
left: -999em; width: 180px; position: absolute;
}
#nav li ul li{
float: left; width: 180px;
background: #F6F6F6;
}
#nav li ul a{ wedisplay: block; width:156px;text-align:left;padding-left:24px;
}
#nav li ul a:link {
color:#666; text-decoration:none;
}
#nav li ul a:visited {
color:#666;text-decoration:none;
}
#nav li ul a:hover {
color:#F3F3F3;text-decoration:none;font-weight:normal;
background:#C00;
}
#nav li:hover ul {
left: auto;
}
#nav li.sfhover ul {
left: auto;
}
#content {
clear: left;
}
-->
</style>
<script type=text/javascript>
<!--//--><![CDATA[//><!--
function menuFix() {
var sfEls =document.getElementByIdx("nav").getElementsByTagName_r("li");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=(this.className.length>0? " ": "") +"sfhover";
}
sfEls[i].onMouseDown=function() {
this.className+=(this.className.length>0? " ": "") +"sfhover";
}
sfEls[i].onMouseUp=function() {
this.className+=(this.className.length>0? " ": "") +"sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp("(?|^)sfhover\b"),
"");
}
}
}
window.onload=menuFix;
//--><!]]>
</script>
</head>
<body>
<ul id="nav">
<li><ahref="#">产品介绍</a>
<ul>
<li><ahref="#">产品一</a></li>
<li><ahref="#">产品一</a></li>
<li><ahref="#">产品一</a></li>
<li><ahref="#">产品一</a></li>
<li><ahref="#">产品一</a></li>
<li><ahref="#">产品一</a></li>
</ul>
</li>
<li><ahref="#">服务介绍</a>
<ul>
<li><ahref="#">服务二</a></li>
<li><ahref="#">服务二</a></li>
<li><ahref="#">服务二</a></li>
<li><ahref="#">服务二服务二</a></li>
<li><ahref="#">服务二服务二服务二</a></li>
<li><ahref="#">服务二</a></li>
</ul>
</li>
<li><ahref="#">成功案例</a>
<ul>
<li><ahref="#">案例三</a></li>
<li><ahref="#">案例</a></li>
<li><ahref="#">案例三案例三</a></li>
<li><ahref="#">案例三案例三案例三</a></li>
</ul>
</li>
<li><ahref="#">关于我们</a>
<ul>
<li><ahref="#">我们四</a></li>
<li><ahref="#">我们四</a></li>
<li><ahref="#">我们四</a></li>
<li><ahref="#">我们四111</a></li>
</ul>
</li>
<li><ahref="#">在线演示</a>
<ul>
<li><ahref="#">演示</a></li>
<li><ahref="#">演示</a></li>
<li><ahref="#">演示</a></li>
<li><ahref="#">演示演示演示</a></li>
<li><ahref="#">演示演示演示</a></li>
<li><ahref="#">演示演示</a></li>
<li><ahref="#">演示演示演示</a></li>
<li><ahref="#">演示演示演示演示演示</a></li>
</ul>
</li>
<li><ahref="#">联系我们</a>
<ul>
<li><ahref="#">联系联系联系联系联系</a></li>
<li><ahref="#">联系联系联系</a></li>
<li><ahref="#">联系</a></li>
<li><ahref="#">联系联系</a></li>
<li><ahref="#">联系联系</a></li>
<li><ahref="#">联系联系联系</a></li>
<li><ahref="#">联系联系联系</a></li>
</ul>
</li>
</ul>
</body>
</html>

三、CSS水平下拉菜单
<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 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>CSS Menu -Horizontal</title>
<style type="text/css">
<!--
@import"dhtml-horiz.css";
-->
body {
margin: 0;
padding: 30px;
background: #FFF;
color: #666;
}
h1 {
font: bold 16px Arial, Helvetica, sans-serif;
}
p {
font: 11px Arial, Helvetica, sans-serif;
}
a {
color: #900;
text-decoration: none;
}
a:hover {
background: #900;
color: #FFF;
}


ul#navmenu {
margin: 0;
border: 0 none;
padding: 0;
width: 500px;
list-style: none;
height: 24px;
}
ul#navmenu li {
margin: 0;
border: 0 none;
padding: 0;
float: left;
display: inline;
list-style: none;
position: relative;
height: 24px;
}
ul#navmenu ul {
margin: 0;
border: 0 none;
padding: 0;
width: 160px;
list-style: none;
display: none;
position: absolute;
top: 24px;
left: 0;
}
ul#navmenu ul li {
float: none;
display: block !important;
display: inline;
}

ul#navmenu a {
border: 1px solid #FFF;
border-right-color: #CCC;
border-bottom-color: #CCC;
padding: 0 6px;
float: none !important;
float: left;
display: block;
background: #EEE;
color: #666;
font: bold 10px/22px Verdana, Arial, Helvetica, sans-serif;
text-decoration: none;
height: auto !important;
height: 1%;
}

ul#navmenu a:hover,
ul#navmenu li:hover a,
ul#navmenu li.iehover a {
background: #CCC;
color: #FFF;
}

ul#navmenu li:hover li a,
ul#navmenu li.iehover li a {
float: none;
background: #EEE;
color: #666;
}

ul#navmenu li:hover li a:hover,
ul#navmenu li:hover li:hover a,
ul#navmenu li.iehover li a:hover,
ul#navmenu li.iehover li.iehover a {
background: #CCC;
color: #FFF;
}

ul#navmenu li:hover li:hover li a,
ul#navmenu li.iehover li.iehover li a {
background: #EEE;
color: #666;
}

ul#navmenu li:hover li:hover li a:hover,
ul#navmenu li:hover li:hover li:hover a,
ul#navmenu li.iehover li.iehover li a:hover,
ul#navmenu li.iehover li.iehover li.iehover a {
background: #CCC;
color: #FFF;
}

ul#navmenu li:hover li:hover li:hover li a,
ul#navmenu li.iehover li.iehover li.iehover li a {
background: #EEE;
color: #666;
}

ul#navmenu li:hover li:hover li:hover li a:hover,
ul#navmenu li.iehover li.iehover li.iehover li a:hover {
background: #CCC;
color: #FFF;
}
ul#navmenu ul ul,
ul#navmenu ul ul ul {
display: none;
position: absolute;
top: 0;
left: 160px;
}

ul#navmenu li:hover ul ul,
ul#navmenu li:hover ul ul ul,
ul#navmenu li.iehover ul ul,
ul#navmenu li.iehover ul ul ul {
display: none;
}
ul#navmenu li:hover ul,
ul#navmenu ul li:hover ul,
ul#navmenu ul ul li:hover ul,
ul#navmenu li.iehover ul,
ul#navmenu ul li.iehover ul,
ul#navmenu ul ul li.iehover ul {
display: block;
}
</style>
<script type="text/JavaScript">
navHover = function() {
var lis =document.getElementByIdx("navmenu").getElementsByTagName_r("LI");
for (var i=0; i<lis.length; i++) {
lis[i].onmouseover=function() {
this.className+=" iehover";
}
lis[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" iehover\b"),"");
}
}
}
if (window.attachEvent) window.attachEvent("onload",navHover);
</script>
</head>
<body>
<h1>CSS Menu -Horizontal</h1>
<hr />
<ul id="navmenu">
<li><ahref="#">Blog</a></li>
<li><ahref="#">Work+</a>
<ul>
<li><ahref="#">Websites+</a>
<ul>
<li><ahref="#">qrayg</a></li>
<li><ahref="#">qArcade</a></li>
<li><ahref="#">qLoM</a></li>
<li><ahref="#">qDT</a></li>
</ul>
</li>
<li><ahref="#">Pen andInk</a></li>
<li><ahref="#">FreeInterfaces</a></li>
</ul>
</li>
<li><ahref="#">Learn+</a>
<ul>
<li><ahref="#"><a href="http://www.jb51.net/list/list_10_1.htm"target="_blank"><fontcolor=red>Fireworks</font></a>+</a>
<ul>
<li><ahref="#">aquaButton</a></li>
<li><ahref="#">aquaButton2</a></li>
<li><ahref="#">waterDrop</a></li>
<li><ahref="#">lightFX</a></li>
<li><ahref="#">lightFX2</a></li>
</ul>
</li>
<li><ahref="#">CSS+</a>
<ul>
<li><ahref="#">footerStick</a></li>
<li><ahref="#">spriteNav</a></li>
<li><ahref="#">@import</a></li>
</ul>
</li>
</ul>
</li>
<li><ahref="#">Info</a></li>
<li><ahref="#">Contact</a></li>
</ul>
</body>
</html>

四、CSS垂直下拉菜单

<!DOCTYPE htmlPUBLIC "-//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>CSS Menu -Vertical</title>
<style type="text/css">
body {
margin: 0;
padding: 30px;
background: #FFF;
color: #666;
}
h1 {
font: bold 16px Arial, Helvetica, sans-serif;
}
p {
font: 11px Arial, Helvetica, sans-serif;
}
a {
color: #900;
text-decoration: none;
}
a:hover {
background: #900;
color: #FFF;
}


ul#navmenu,
ul#navmenu li,
ul#navmenu ul {
margin: 0;
border: 0 none;
padding: 0;
width: 160px;
list-style: none;
}
ul#navmenu li {
display: block !important;
display: inline;
position: relative;
}

ul#navmenu a {
border: 1px solid #FFF;
border-right-color: #CCC;
border-bottom-color: #CCC;
padding: 0 6px;
display: block;
background: #EEE;
color: #666;
font: bold 10px/22px Verdana, Arial, Helvetica, sans-serif;
text-decoration: none;
height: auto !important;
height: 1%;
}

ul#navmenu a:hover,
ul#navmenu li:hover a,
ul#navmenu li.iehover a {
background: #CCC;
color: #FFF;
}

ul#navmenu li:hover li a,
ul#navmenu li.iehover li a {
background: #EEE;
color: #666;
}

ul#navmenu li:hover li a:hover,
ul#navmenu li:hover li:hover a,
ul#navmenu li.iehover li a:hover,
ul#navmenu li.iehover li.iehover a {
background: #CCC;
color: #FFF;
}

ul#navmenu li:hover li:hover li a,
ul#navmenu li.iehover li.iehover li a {
background: #EEE;
color: #666;
}

ul#navmenu li:hover li:hover li a:hover,
ul#navmenu li:hover li:hover li:hover a,
ul#navmenu li.iehover li.iehover li a:hover,
ul#navmenu li.iehover li.iehover li.iehover a {
background: #CCC;
color: #FFF;
}

ul#navmenu li:hover li:hover li:hover li a,
ul#navmenu li.iehover li.iehover li.iehover li a {
background: #EEE;
color: #666;
}

ul#navmenu li:hover li:hover li:hover li a:hover,
ul#navmenu li.iehover li.iehover li.iehover li a:hover {
background: #CCC;
color: #FFF;
}
ul#navmenu ul,
ul#navmenu ul ul,
ul#navmenu ul ul ul {
display: none;
position: absolute;
top: 0;
left: 160px;
}

ul#navmenu li:hover ul ul,
ul#navmenu li:hover ul ul ul,
ul#navmenu li.iehover ul ul,
ul#navmenu li.iehover ul ul ul {
display: none;
}
ul#navmenu li:hover ul,
ul#navmenu ul li:hover ul,
ul#navmenu ul ul li:hover ul,
ul#navmenu li.iehover ul,
ul#navmenu ul li.iehover ul,
ul#navmenu ul ul li.iehover ul {
display: block;
}
</style>
<script type="text/javascript">
<!--
navHover = function() {
var lis =document.getElementByIdx("navmenu").getElementsByTagName_r("LI");
for (var i=0; i<lis.length; i++) {
lis[i].onmouseover=function() {
this.className+=" iehover";
}
lis[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" iehover\b"),"");
}
}
}
if (window.attachEvent) window.attachEvent("onload",navHover);
-->
</script>
</head>
<body>
<h1>CSS Menu -Vertical</h1>
<hr />
<ul id="navmenu">
<li><ahref="#">Blog</a></li>
<li><ahref="#">Work+</a>
<ul>
<li><ahref="#">Websites+</a>
<ul>
<li><ahref="#">qrayg</a></li>
<li><ahref="#">qArcade</a></li>
<li><ahref="#">qLoM</a></li>
<li><ahref="#">qDT</a></li>
</ul>
</li>
<li><ahref="#">Pen andInk</a></li>
<li><ahref="#">FreeInterfaces<

  

爱华网本文地址 » http://www.413yy.cn/a/25101015/280596.html

更多阅读

教你打开任务管理器的多种方法 精 无法打开任务管理器

教你打开任务管理器的多种方法 精——简介 任务管理器是经常要用到的程序,在任务管理器中所有的程序和服务都显示了出来,我们可以了解系统正在运行着哪些程序和服务,我们也可以用它来结束一些程序和服务。而且有一些恶意的软件并不能被

声明:《用CSS实现自动下拉菜单的多种方法 css导航栏下拉菜单》为网友证明给你看分享!如侵犯到您的合法权益请联系我们删除