}
就可以了。如果想鼠标移动后,出现下拉列表,我没看到楼主定义这个类型,所以给楼主一个我以前写的,仅供参考。
.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 {}
css制作横排二级下拉菜单,代码如下:
<body>
<ul id="FM">
<li><a href="#">一级栏目</a>
<ul>
<li><a href="#">二级菜单</a></li>
<li><a href="#">二级菜单</a></li>
<li><a href="#">二级菜单</a></li>
</ul>
</li>
<li><a href="#">一级栏目</a>
<ul>
<li><a href="#">二级菜单</a></li>
<li><a href="#">二级菜单</a></li>
<li><a href="#">二级菜单</a></li>
</ul>
</li>
<li><a href="#">一级栏目</a>
<ul>
<li><a href="#">二级菜单</a></li>
<li><a href="#">二级菜单</a></li>
<li><a href="#">二级菜单</a></li>
</ul>
</li>
</ul>
</body>
CSS样式设置代码,如下;
<style type="text/css">
ul#FM li {
float:left
width:160px
list-style:none
}
ul#FM li ul {
display:none
margin:0
padding:0
}
ul#FM li:hover ul{
display:block
}
ul#FM li a{
display:block
border:1px solid red
text-decoration:none
color:#000
}
ul#FM li li a {
display:block
font-size:12px
border:1px solid green
padding:3px
text-decoration:none
width:152px
color:#CC3399
}
ul#FM>li li a {
width:auto
}
</style>
所做出来的效果,鼠标放上去时,如图;
设置子菜单项的样式分为3步 1、首先对每个子菜单项,也就是dd元素进行常规设置,包括内外边距清零,设置文字颜色等。/* 设置菜单项的dd */
#menu li dd {margin:0padding:0color: #fff
} 2、为了使最后一个dd的下端有一条分割线,我们设置它为1px的红色下边框,这就使之与上边框的红色分割线想对应了,也告诉浏览者这是一块可以点击的区域。
#menu li dd.last {
border-bottom:1px solid #b00
} 上面的代码也新增了一个last的类,因此我们必须在对应的HTML代码中最后一个dd指定class="last"。
CSS高级教程 3、设置子菜单的链接的样式
#menu li dd a, #menu li dd a:visited {
display:block
color:#FFF
text-decoration:none
padding:5px 20px
background: #0000FF}此时,我们在浏览器就可以看到下拉菜单的样式已经可以显示了。 二、设置鼠标经过时的响应
最后一条规则,让鼠标滑过有下拉项的时候,显示下拉菜单。当然我们实际设置的是:如果某一个下拉菜单的父级元素(一级菜单项)被鼠标滑过,那么就让该下拉菜单可以被看见:
#menu li dd { visibility: visible}
background: #0000FF}最后我们就可以运行整个文件实现效果了,建站教程网建议大家一起跟着步骤一步一步的做哦。