水平方向的PopMenu-弹出菜单(DIV+CSS+JS)
此POPMENU根据alistapart的articles改编,比DW中用显示、隐藏层的方法要简单。在IE6.0 IE5.X Firefox NS都能正确显示,只用到很少的JS代码,使用时只要把
水平式菜单鼠标经过时弹出子菜单:
参考代码:
li ul {
display: none; left: -40px; position: absolute; top: 24px;
width: 490px; /*opera需要这个宽度,可根据导航条的实际宽度作调整*/
}
li ul li{
display: inline;
}
li ul li a{
background: url(h_line.gif) no-repeat 0px 7px; color: #666666;
font-weight: normal; padding: 6px; text-align: left;
}
li ul li a:hover{
background: url(h_line.gif) no-repeat 0px 7px; color: #DC4E1B; text-decoration: underline;
}
li ul,li ul li{
border: 0px;
}
li:hover ul, li.over ul,ul li:hover {
display: block;
}
ul {
list-style: none; margin: 0px; padding: 0px; font: normal 11px verdana;
}
ul li {
border: solid 1px #CCCCCC; border-left: 0px; float: left; position: relative;
}
ul li a {
background: #F5F5F5; color: #666666; display: block; font-weight: bold;
padding: 5px 10px; text-align: center; text-decoration: none;
}
ul li a:hover {
background: #DC4E1B; color: #FFFFFF;
}
.left{
height: 24px; width: 1px;
}
html:
垂直式菜单鼠标经过时弹出子菜单:
参考代码:
body {
font-family: Arial, Helvetica, sans-serif; font-size: 11px;
}
#nav, #nav ul {
list-style: none; background: #F9F9F9; font-weight: bold;
padding: 0px; margin: 0px; border: solid 1px #CCCCCC; border-bottom: 0px;
width: 180px; text-align: left;
}
#nav ul ul{
border: solid 1px #CCCCCC;
border-bottom: 0px;
}
#nav a {
display: block; width: 180px; w/idth: 180px;
color: #333333; text-decoration: none; text-align: center;
border-bottom: solid 1px #CCCCCC; text-align: left;
padding-left: 10px;
}
#nav a:hover{ color: #336666; }
#nav a.selected{
background: url(../images/arrow.gif) no-repeat right 50%;
}
#nav li {
line-height: 22px; position: relative;
}
#nav li ul {
position: absolute;
left: -99em; width: 150px; font-weight: normal;
margin: 0px; padding: 0px;
}
#nav li li { width: 150px; }
#nav li ul a {
width: 150px;
w/idth: 126px;
padding: 0px 12px;
line-height: 22px;
text-align: left;
}
#nav li ul ul {
margin: 0px 0 0 150px;
}
#nav li:hover ul ul,#nav li.sfhover ul ul{
left: -999em;
}
#nav li:hover ul, #nav li li:hover ul,#nav li.sfhover ul, #nav li li.sfhover ul{
left: auto;
}
#nav li:hover ul,#nav li.sfhover ul{
left: 180px; top: 0px;
}
#nav li:hover, #nav li.sfhover {
background: #F5E3C0;
}
* html #nav li {
float: left;
height: 1%;
}
* html #nav li a {
height: 1%;
}