Aram Mkrtchyan的回答幾乎就在我身邊。與他的問題是,如果你添加菜單下面的任何東西,那麼它會變得一團糟。這裏是什麼,我的意思是一個例子,我在下面他的菜單一個div: http://jsfiddle.net/4jxph/3418/
我使用DIV而不是列表,列表項(我覺得這更容易的工作,和方式更加提交這個更新的答案靈活)和jQuery版本1.9。1
這裏是鏈接jFiddle: http://jsfiddle.net/4jxph/3423/
下面是代碼:
--------------- HTML:
<div id="divMenuWrapper1" class="divMenuWrapper1">
<div id="hoverli">
<div class="lbtn">
Actions
</div>
<div id="actions_menu" class="file_menu">
<div><a href="#file">File</a></div>
<div><a href="#edit">Edit</a></div>
<div><a href="#view">View</a></div>
<hr />
<div><a href="#insert">Insert</a></div>
<div><a href="#modify">Modify</a></div>
<div><a href="#control">Control</a></div>
<div><a href="#debug">Debug</a></div>
<div><a href="#window">Window</a></div>
<div><a href="#help">Help</a></div>
</div>
</div>
</div>
<div>
testing content below menu testing content below menu testing content below menu testing content below menu testing content below menu testing content below menu testing content below menu testing content below menu testing content below menu testing content below menu testing content below menu testing content below menu testing content below menu testing content below menu
</div>
--------------- Css:
.lbtn
{
display:inline-block;
cursor:pointer;
height:20px;
background-color:silver;
background-repeat:repeat-x;
border:1px solid black; /* dark navy blue */
text-decoration:none;
font-size:11pt;
text-align:center;
line-height:20px;
padding:0px 10px 0px 10px;
}
.divMenuWrapper1
{
height: 25px;
width: 75px;
}
.file_menu
{
display:none;
width:250px;
border: 1px solid #1c1c1c;
background-color: white;
position:relative;
z-index:100000;
}
.file_menu div
{
background-color: white;
font-size:10pt;
}
.file_menu div a
{
color:gray;
text-decoration:none;
padding:3px;
padding-left:15px;
display:block;
}
.file_menu div a:hover
{
padding:3px;
padding-left:15px;
text-decoration:underline;
color: black;
}
--------------- jQuery(將被放置在document.ready或p ageLoad()):
$("#hoverli").hover(
function() {
$('#actions_menu').finish().slideDown('fast');
},
function() {
$('#actions_menu').finish().slideUp('fast');
}
);
能你發佈了一個鏈接到科莫多編輯版本?我認爲問題在於jQuery不包含在jsdo.it中。 – Purag 2012-01-08 06:42:17
是的,對不起。我真的很累,早上1點,我不想去麻煩。 – Matt 2012-01-08 16:51:33