jQuery + CSS3을 사용하여 메뉴 작업을하고 있습니다.CSS + jQuery 토글 메뉴
나는 메뉴의 오른쪽에 위쪽 화살표가 있으며 클릭하면 메뉴가 위로 움직이고 이미지가 아래쪽 화살표로 바뀝니다.
유일하게 문제가되는 것은 아래쪽 화살표를 클릭하면 작동하기 위해 다소 합법적 인 코드 조각을 제공했지만 다시 아래로 슬라이드하지 않는 것입니다.
저는 jquery를 처음 사용하므로 어떤 도움을 주셔서 감사합니다!
HTML :
<nav id="tfc-new-nav">
<div class="wrapper">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="cart.html">Shopping Cart</a></li>
<li><a href="login.html">My Account</a></li>
</ul>
</div>
<div class="hide-menu menu-active"></div>
</nav>
CSS :
.wrapper {
display: block;
height: 100%;
width: 1000px;
position: relative;
margin: 0 auto;
}
#tfc-new-nav {
display: block;
height: 45px;
width: 100%;
background: #808E91;
position: relative;
top: 50px;
}
#tfc-new-nav ul {
list-style: none;
}
#tfc-new-nav ul li {
display: block;
height: 45px;
width: 10%;
float: left;
text-align: center;
line-height: 45px;
}
#tfc-new-nav ul li a {
display: block;
color: #fff;
text-decoration: none;
text-transform: uppercase;
font-family: 'Felix Titling', serif;
cursor: pointer;
-webkit-transition: background .3s ease-in;
-moz-transition: background .3s ease-in;
-ms-transition: background .3s ease-in;
-o-transition: background .3s ease-in;
transition: background .3s ease-in;
}
#tfc-new-nav ul li a:hover {
background: #50798D;
}
#tfc-new-nav .hide-menu {
position: absolute;
top: 20px;
right: 10px;
cursor: pointer;
}
#tfc-new-nav .hide-menu.menu-active {
display: block;
background-image: url('http://upload.wikimedia.org/wikipedia/commons/6/61/Black_Up_Arrow.png');
background-size: 100% 100%;
height: 7px;
width: 7px;
}
#tfc-new-nav .hide-menu.menu-hidden {
display: block;
background-image: url('http://www.wpclipart.com/signs_symbol/BW/direction_arrows/down_arrow.png');
background-size: 100% 100%;
height: 7px;
width: 7px;
}
자바 스크립트 :
$(document).ready(function() {
$("#tfc-new-nav .hide-menu.menu-active").click(function() {
$("#tfc-new-nav").animate({
top: "30px"
});
$(this).removeClass("menu-active");
$(this).addClass("menu-hidden");
$(this).animate({
top: "35px"
});
});
$("#tfc-new-nav .hide-menu.menu-hidden").click(function() {
$("#tfc-new-nav").animate({
top: "95px"
});
$(this).removeClass("menu-hidden");
$(this).addClass("menu-active");
$(this).animate({
top: "20px"
});
});
});
실제로 메뉴 상단에있는 메뉴 위의 헤더가 있지만 실제로는 실제 페이지에는 포함되지 않습니다. 그러나 그것은 당신에게 아이디어를 줄 것입니다. – ModernDesigner
헤더를 포함하도록 바이올린을 업데이트했습니다. – ModernDesigner