}
就可以了。如果想鼠标移动后,出现下拉列表,我没看到楼主定义这个类型,所以给楼主一个我以前写的,仅供参考。
.imcm ul,.imcm li,.imcm div,.imcm span,.imcm a{text-align:leftvertical-align:toppadding:0pxmargin:0list-style:none outside noneborder-style:nonebackground-image:noneclear:nonefloat:nonedisplay:blockposition:staticoverflow:visibleline-height:normal}
.imcm li a img{display:inlineborder-width:0px}
.imcm span{display:inline}
.imcm .imclear,.imclear{clear:bothheight:0pxvisibility:hiddenline-height:0pxfont-size:1px}.imcm .imsc{position:relative}.imcm .imsubc{position:absolutevisibility:hidden}.imcm li{list-style:nonefont-size:1pxfloat:left}.imcm ul ul li{width:100float:left !important}
.imcm a{display:blockposition:relative}
.imcm ul .imsc,.imcm ul .imsubc {z-index:10}
.imcm ul ul .imsc,.imcm ul ul .imsubc{z-index:20}
.imcm ul ul ul .imsc,.imcm ul ul ul .imsubc{z-index:30}
.imde ul li:hover .imsubc{visibility:visible}
.imde ul ul li:hover
.imsubc{visibility:visible}
.imde ul ul ul li:hover
.imsubc{visibility:visible}
.imde li:hover ul .imsubc{visibility:hidden}
.imde li:hover ul ul .imsubc{visibility:hidden}
.imde li:hover ul ul ul .imsubc{visibility:hidden}
.imcm .imea{display:blockposition:relativeleft:0pxfont-size:1pxline-height:1pxheight:0pxwidth:1pxfloat:right}
.imcm .imea span{display:blockposition:relativefont-size:1pxline-height:0px}.dvs,.dvm{border-width:0px}/*\*//*/.imcm .imea{visibility:hidden}/**/</style><!--[if IE]><style type="text/css">.imcm .imea span{position:absolute}.imcm .imclear,.imclear{display:none}.imcm{zoom:1} .imcm li{curosr:hand} .imcm ul{zoom:1}.imcm a{zoom:1}</style><![endif]--><!--[if gte IE 7]><style type="text/css">.imcm .imsubc{background-image:url(ie_css_fix)}</style><![endif]--><!--end-->
<!--[imstyles] *** Infinite Menu Styles: Keep this section in the document head for full validation. -->
<style type="text/css">
/* --[[ Main Expand Icons ]]-- */
#imenus0 .imeam span,#imenus0 .imeamj span {background-image:url(bg-daohangS.jpg)width:1pxheight:12pxleft:0pxtop:0pxbackground-repeat:no-repeatbackground-position:top left}
#imenus0 li:hover .imeam span,#imenus0 li a.iactive .imeamj span {background-image:url(bg-daohangS.jpg)background-repeat:no-repeatbackground-position:top left}
/* --[[ Sub Expand Icons ]]-- */
#imenus0 ul .imeas span,#imenus0 ul .imeasj span {background-image:url(stub_arrow_right.gif)width:6pxheight:8pxleft:0pxtop:3pxbackground-repeat:no-repeatbackground-position:top left}
#imenus0 ul li:hover .imeas span,#imenus0 ul li a.iactive .imeasj span {background-image:url(stub_arrow_right.gif)background-repeat:no-repeatbackground-position:top left}
/* --[[ Main Container ]]-- */
#imouter0 {background-color:#95D4CCborder-style:noneborder-color:#CCCCCCborder-width:1pxpadding:0pxmargin:0px}
/* --[[ Sub Container ]]-- */
#imenus0 li ul {background-color:#95d4ccborder-style:solidborder-color:#687a54border-width:1pxpadding:5px 8px 5px 5pxmargin:0px}
/* --[[ Main Items ]]-- */
#imenus0 li a, #imenus0 .imctitle {height:16pxbackground-color:#95D4CCcolor:#000text-align:leftfont-family:Arialfont-size:12pxfont-weight:normaltext-decoration:none padding:3px 6px 1pxmargin:0px 5px 0px 0px}
/* [hover] - These settings must be duplicated for IE compatibility.*/
#imenus0 li:hover>a {background-color:#5B9890text-decoration:none}
#imenus0 li a.ihover, .imde imenus0 a:hover {background-color:#95d4cctext-decoration:none}
/* [active] */
#imenus0 li a.iactive {}
/* --[[ Sub Items ]]-- */
#imenus0 ul a, #imenus0 .imsubc li .imctitle {height:autobackground-color:transparentcolor:#000text-align:leftfont-size:11pxfont-weight:normaltext-decoration:noneborder-style:solidborder-color:#95d4ccborder-width:1px 0pxpadding:2px 5pxmargin:0px}
/* [hover] - These settings must be duplicated for IE comptatibility.*/
#imenus0 ul li:hover>a {background-color:#5B9890text-decoration:noneborder-color:#687a54}
#imenus0 ul li a.ihover {background-color:#5B9890text-decoration:noneborder-color:#687a54}
/* [active] */
#imenus0 ul li a.iactive {}
工具/材料notepad++
浏览器
打开Notepad++,先输入个页面框架<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<hade>
</hade>
<body>
</body>
框架好了,那么就该定义页面的title,关键词keyword,和描述description<meta charset="UTF-8" content="text/html" http-equiv="content-type">
<title>纯css二级导航下拉菜单</title>
<meta name="keyword" content="搜狗略懂">
<meta name="description" content="描述">
这些内容只能在<head></head>中完成。
定义页面使用的css样式,也是需要在<head>里定义的。<style type="text/css">
* {
margin:0
padding:0
}
.jiao ul li a:hover{
color:#red
}
ul, li {
list-style:none
}
a {
text-decoration:none
}
.jiao {
border:5px solid #pink
border-right:none
overflow:hidden
float:left
margin:200px 0 0 600px
}
.jiao ul li ul li a {
border-right:solid
border-top:2px dotted #666
background:#black
}
.jiao>ul>li { float:left}
.jiao ul li a { width:150pxheight:80pxtext-align:centerline-height:100pxdisplay:blockborder-right:5px solid #redbackground:#redcolor:#red}
.jiao ul li ul { position:absolutedisplay:none}
.jiao ul li:hover ul{ display:block}
.jiao>ul>li>ul>li { float:none}
<!--nav>ul只选择nav下一级里面的ul元素
nav ul选择nav内所包含的所有ul元素
nav>ul比nav ul限定更严格,必须后面的元素只比前面的低一个级别。
这里根据你的需求来自己定义。
-->
</style>
添加一个DIV标签,在页面中划分出一个块来,用来显示。div中所用的样式为刚才咱们声明的样式“jiao”这个盒子来描述
然后使用无序标签<ul>+样式<li>来实现模块。<div class="jiao">
<ul>
<li><a href="#">搜狗略懂</a>
<ul>
<li><a href="#">搜狗问问</a></li>
<li><a href="#">搜狗输入法</a></li>
<li><a href="#">搜狗浏览器</a></li>
<li><a href="#">搜狐</a></li>
</ul>
</div>
放上全部的代码吧,可以参考一下啊,<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">//允许你通过一个网址来识别你的标记
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />
<meta name="keyword" content="利用css实现下拉菜单">
<meta name="description" content="搜狗略懂、css分享">
<title>css实现下拉导航栏菜单</title>
<style type="text/css">
* {
margin:0
padding:0
}
.jiao ul li a:hover{
color:#red
}
ul, li {
list-style:none
}
a {
text-decoration:none
}
.jiao {
border:5px solid #pink
border-right:none
overflow:hidden
float:left
margin:200px 0 0 600px
}
.jiao ul li ul li a {
border-right:solid
border-top:2px dotted #666
background:#black
}
.jiao>ul>li { float:left}
.jiao ul li a { width:150pxheight:80pxtext-align:centerline-height:100pxdisplay:blockborder-right:5px solid #redbackground:#redcolor:#red}
.jiao ul li ul { position:absolutedisplay:none}
.jiao ul li:hover ul{ display:block}
.jiao>ul>li>ul>li { float:none}
<!--nav>ul只选择nav下一级里面的ul元素
nav ul选择nav内所包含的所有ul元素
nav>ul比nav ul限定更严格,必须后面的元素只比前面的低一个级别。
这里根据你的需求来自己定义。
-->
</style>
</head>
<body>
<div class="jiao">
<ul>
<li><a href="#">搜狗略懂</a>
<ul>
<li><a href="#">搜狗问问</a></li>
<li><a href="#">搜狗输入法</a></li>
<li><a href="#">搜狗浏览器</a></li>
<li><a href="#">搜狐</a></li>
</ul>
</li>
</ul>
</div>
</body>
</html>
如果要添加更多的菜单,只需要后边继续添加<ul>/<li>即可
特别提示写代码过程中一定要记得换行,开头留空,否则过后找东西,连你自己都不知道写的是什么。何谈从哪里找起?