我已經制作了帶有DIVs的這個水平菜單(根本沒有ul和li列表),我正在尋找一種方法來延遲子菜單在鼠標上的粘連出來,不介意是否與JavaScript,jQuery或CSS。 我嘗試了一些JavaScript解決方案,但都沒有工作。延遲關閉菜單上的子菜單專用divs製作
的CSS
.topmenu
{
margin: 0 auto; width: auto;float:left;
position:relative;
z-index:4;
height: 50px;
font-family: Arial, Helvetica, sans-serif;
font-size:16px;
color:#444;
}
.topmenu a
{
padding:0 16px;
line-height:50px; /*Note: keep this value the same as the height of .topmenu */
font-size:16px;
font-weight:normal;
display:block;
outline:0;
text-decoration: none;
position:relative;
color:#444;
}
.topmenu .home, .topmenu .button1, .topmenu .button2 {float: left;}
.topmenu .home img {vertical-align: top; margin-top:8px; border:none;}
.topmenu .home:hover a, .topmenu .button1:hover a, .topmenu .button2:hover a
{background-color:#333; color:#FFF; z-index:9;}
.topmenu .subhome,
.topmenu .submenu1,
.topmenu .submenu2
{
position: absolute;
right:0;
z-index:20;
display:none;
background-color:#0e5079;
text-align: left;
padding: 20px;
top:50px;
color:#999;
border-radius:3px;
-moz-box-shadow:1px 2px 12px #333333;
-webkit-box-shadow:1px 2px 12px #333333;
box-shadow:1px 2px 12px #333333;
text-shadow:
-1px -1px 0 #333,0px -1px 0 #333,1px -1px 0 #333,-1px 1px 0 #333,0px 1px 0 #333,1px 1px 0 #333;
}
.topmenu .home:hover .subhome {display:block;}
.topmenu .button1:hover .submenu1 {display:block;}
.topmenu .button2:hover .submenu2 {display:block;}
.topmenu .subhome {
width:960px;
height:560px;
background-image:url(menu/menu-bg/corfu-bw-bg.jpg);
background-repeat:no-repeat;
background-position:center;
}
.topmenu .submenu1 {
background-image:url(menu/menu-bg/benitses-bg.jpg);
background-repeat:no-repeat;
background-position:center;
}
.topmenu .submenu2 {
background-image:url(menu/menu-bg/corfu-bg.jpg);
background-repeat:no-repeat;
background-position:center;
}
.topmenu .submenuleft {padding:20px;float:left;}
.topmenu .submenuleft span {font-weight:bold; font-size:16px;color:#DDD;line- height:32px;}
.topmenu .submenuleft a span {font-weight:bold; font-size:16px;color:#FA0;padding- top:5px;padding-bottom:8px;}
.topmenu .submenuleft a span:hover {color:#FF0; text-decoration:none;}
.topmenu .submenuleft a:hover {color:#FF0;font-size:14px;text-decoration:none;background:none;}
.topmenu .submenuleft img {display:block;border:#FFF 2px solid;padding:4px;margin-top:5px;}
.topmenu .subhome .submenuleft a,
.topmenu .submenu1 .submenuleft a,
.topmenu .submenu2 .submenuleft a
{
padding:0px;
line-height:26px;
font-size:14px;
background:none;
display: inline;
text-align:left;
z-index: 0;
}
和HTML
<div class="topmenu">
<div class="home"><a href="#">HOME</a>
<div class="subhome">
</div>
</div>
<div class="button1"><a href="#">ITEM1</a>
<div class="submenu1" style="width:840px;">
<div class="submenuleft">
<a href="#"><span>LINK TITLE</span></a><br>
<a href="#">Example link</a><br>
<a href="#">Example link</a><br>
<a href="#">Example link</a><br>
<a href="#">Example link</a>
</div>
<div class="submenuleft">
<a href="#"><span>LINK TITLE</span></a><br>
<a href="#">Example link</a><br>
<a href="#">Example link</a>
</div>
<div class="submenuleft">
<a href="#"><span>LINK TITLE</span></a><br>
<a href="#">Example link</a><br>
<a href="#">Example link</a><br>
<a href="#">Example link</a><br>
<a href="#">Example link</a><br>
<a href="#">Example link</a>
</div>
<div class="submenuleft" style="text-align:right;width:130px;">
<img src="menu/benitses-m.jpg" alt="" style="width:128px; height:200px; height:190px;margin-top:5px;">
</div>
</div>
</div>
<div class="button2"><a href="#">ITEM2</a>
<div class="submenu2" style="width:800px;">
<div class="submenuleft">
<a href="#"><span>LINK TITLE</span></a><br>
<a href="#">Example link</a><br>
<a href="#">Example link</a><br>
<a href="#">Example link</a>
</div>
<div class="submenuleft">
<a href="#"><span>LINK TITLE</span></a><br>
<a href="#"><span>LINK TITLE</span></a><br>
<a href="#">Example link</a><br>
<a href="#">Example link</a>
</div>
<div class="submenuleft">
<a href="#">Example link</a><br>
<a href="#">Example link</a><br>
<a href="#">Example link</a>
</div>
<div class="submenuleft" style="text-align:right; width:140px;">
<img src="menu/mouse-island.jpg" alt="" style="width:140px; height:210px;">
</div>
</div>
</div>
你可以看到這個菜單的測試例here
謝謝
淡出?在jQuery – niko