當我點擊一個按鈕時,我製作了一個菜單,其中的滑動條向下打開。然而,我的菜單的內容只顯示了50%的時間......我真的不知道如何解決這個問題。 因此,基本上你點擊打開的菜單,它顯示正常,但當我關閉並重新打開它不顯示我的內容...當點擊打開菜單時,菜單內容只顯示50%的時間
我使用html,css和jquery獲得此效果。
我做了一個codepen:Codepen
$(document).ready(function() {
var clicks = 0;
$('.menubutton-tablet').click(function() {
if (clicks % 2 == 0) {
$('.menu-collapse-tablet').animate({
'height': '375px'
}, 500);
$('.navbar-ul-tablet').toggleClass('slideopen');
} else {
$('.menu-collapse-tablet').animate({
'height': '0px'
}, 500)
$('.navbar-ul-tablet').toggleClass('menutoggle');
}
++clicks
});
});
nav {
width: 100%;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
flex-direction: column;
background: black;
background-position: center;
display: flex;
}
.navbar-styles {
border-radius: 0px;
border-style: none;
border-color: none;
min-height: 100px;
margin-bottom: 0;
background-color: transparent;
width: 100%;
display: flex;
justify-content: space-between;
}
.headerlinks {
position: relative;
text-decoration: none;
list-style-type: none;
color: white;
}
.headerlogo {
width: 225px;
margin-left: 10%;
float: left;
position: relative;
display: inline;
}
.menubutton-tablet {
width: 100px;
height: 100px;
margin-top: 1%;
cursor: pointer;
color: white;
}
.menubutton-tablet:hover {
opacity: 0.8;
}
.menu-collapse-tablet {
display: flex;
width: 100%;
height: 0px;
justify-content: center;
background: transparent;
}
.navbar-ul-tablet {
display: none;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-flex-direction: column;
flex-direction: column;
}
.slideopen {
display: flex;
}
.menutoggle {
display: none;
}
.navbar-ul-tablet li {
text-decoration: none;
list-style-type: none;
font-size: 18px;
padding-top: 50px;
text-shadow: 3px 2px 4px rgba(0, 0, 0, 0.50);
}
.navbar-ul-tablet li:first-child {
padding-top: 10px;
}
.navbar-ul-tablet li:last-child {
padding-bottom: 20px;
}
.headerlinks {
color: white;
font-weight: 100;
}
.headerlinks:hover {
color: #d0021b;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<nav>
<div class="navbar-styles">
<a href="index.php">
<img class="headerlogo" src="images/mobilelogo2.png" />
</a>
<p class="menubutton-tablet">Open Menu</p>
</div>
<div class="menu-collapse-tablet">
<ul class="navbar-ul-tablet">
<li><a class="headerlinks" href="assortiment.php">ASSORTIMENT</a>
</li>
<li><a class="headerlinks" href="overons.php">OVER ONS</a>
</li>
<li><a class="headerlinks" href="webshop.php">WEBSHOP</a>
</li>
<li><a class="headerlinks" href="#">LOGIN</a>
</li>
<li><a class="headerlinks" href="contact.php">CONTACT</a>
</li>
</ul>
</div>
</nav>
Thx,像一個魅力一樣工作猜測它沒有必要隱藏容器內的內容... – Pieter