當鼠標離開這個div時,我得到了webdsn-drop,但是當鼠標離開#web按鈕時它仍然保持不動。當鼠標關閉#web按鈕和#webdsn-drop時,如何讓div消失當鼠標離開觸發器並滑下內容時,如何編碼滑下的內容以便滑動?
謝謝大家的幫助!
HTML:
<div id="navbar">
<div id="nav-container">
<h1>PORTFOLIO</h1>
<a href="#">Logo Design</a>
<a href="#">Business Cards</a>
<a id="pf" href="posters+flyers.html">Posters & Flyers</a>
<a id="web" href="#">Website Design</a>
</div>
</div>
<div id="webdsn-drop">
<div id="border">
<h1>WEBSITE DESIGN</h1>
</div>
</div>
<div id="pfdsn-drop">
<div id="border">
<h1>POSTERS & FLYERS</h1>
</div>
</div>
CSS:
#navbar {
width: 100%;
background-color: #fcfcfc;
overflow: auto;
position: fixed;
left: 0px;
top: 0px;
overflow: hidden;
z-index: 10;
}
#nav-container {
max-width: 950px;
min-width: 745px;
margin: 0 auto;
}
#nav-container h1 {
float: left;
margin: 0 auto;
padding-top: 10px;
font-family: "calibri light";
font-size: 25px;
letter-spacing: 0.3em;
margin-left: 5px;
transition: color 0.3s ease;
}
#nav-container a {
float: right;
display: block;
padding: 15px 15px;
text-decoration: none;
color: black;
font-family: "calibri light", sans-serif;
font-size: 18px;
transition: background-color 0.5s ease;
}
#nav-container a:hover {
background-color: #f4f4f4;
transition: background-color 0.5s ease;
}
#nav-container a:active {
background-color: #bfbfbf;
}
#nav-container h1:hover {
color: #aaaaaa;
transition: color 0.3s ease;
}
/*-----------WEB-DESIGN-DROP---------*/
#border{
width: 950px;
margin: 0 auto;
}
#border h1{
position: absolute;
border: solid;
border-color: white;
border-width: 1px;
display: inline;
padding: 10px 20px;
border-radius: 10px;
}
#webdsn-drop{
background-color: #3f3f3f;
margin-top: 50px;
width: 100%;
position: fixed;
left: 0px;
top: 0px;
z-index: 9;
font-family: 'calibri light';
font-size: 12px;
letter-spacing: 5px;
height: 400px;
color: white;
display: none;
}
JQUERY:
$(document).ready(function(){
$('#web').hover(function() {
$('#webdsn-drop').slideDown();
}, function() {
$('#webdsn-drop').mouseleave(function(){
$('#webdsn-drop').slideUp();
});
});
});
我試過這個,但滑動下來的內容不停留,當moise移動到它,它已幫助導航按鈕部分,但我想滑下來的內容保持滑下來,直到鼠標也走了 – AbuN2286