我正在iPhone 5上测试我的代码而我的'导航图标'没有显示出来。当我使用chrome中的开发人员工具模拟移动视图时,它可以很好地工作,但是在真正的手机上却没有。
$(document).ready(function(){
$('#nav-icon').click(function(){
$(this).toggleClass('open');
});
// $('#nav-icon').on("click", function(){
// $("ul").toggleClass('open1');
// });
$("#nav-icon").click(function(){
// $("ul").fadeToggle();
$("ul").slideToggle(500);
// $("#div3").fadeToggle(3000);
});
});
nav {
background-color: #252525;
display: flex;
justify-content: space-between;
align-items: center;
color: #686868;
font-size: 22px;
border-radius: 5px 5px 0 0;
font-family:arial;
}
.box-1,
.box-2,
.box-3 {
flex: 1;
height: 100%;
display: flex;
justify-content: center;
letter-spacing: 2px;
}
.box-2 {
display: flex;
flex-direction: column;
align-items: center;
}
.box-1,
.box-2 {
display: flex;
align-items: center;
grow-flex: 1;
}
ul {
overflow: hidden;
background-color: #505050;
display: none;
padding: 0;
margin: 0;
list-style: none;
text-align: center;
animation-name: test1;
animation-duration: 1s;
timing-function: ease-in-out;
perspective: 1000px;
}
ul.open1 {
height: auto;
//background-color: red;
animation-name: test;
animation-duration: 500ms;
animation-timing-function: ease-in-out;
}
@keyframes test {
0% {opacity: 0;}
transform: rotateY(-90deg)
translateY(30px);
100% {opacity: 1;}
transform: rotateY(0deg) translateY(0px);
}
@keyframes test1 {
0% {opacity: 100%;}
100% {opacity: 0%;}
}
ul li {
border-bottom: 1px solid #404040;
}
ul li a {
color: #686868;
font-size: 22px;
text-decoration: none;
display: block;
padding: 10px;
}
li:hover {
background: grey;
color: #252525;
}
#nav-icon, #nav-icon2, #nav-icon3, #nav-icon4 {
width: 60px;
height: 45px;
position: relative;
margin: 4% auto;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
transition: .7s ease-in-out;
cursor: pointer;
}
#nav-icon span, #nav-icon3 span, #nav-icon4 span {
display: block;
position: absolute;
height: 9px;
width: 100%;
background: #686868;
border-radius: 9px;
opacity: 1;
left: 0;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
transition: .5s ease-in-out;
}
#nav-icon span:nth-child(1) {
top: 0px;
}
#nav-icon span:nth-child(2) {
top: 18px;
}
#nav-icon span:nth-child(3) {
top: 36px;
}
#nav-icon.open span:nth-child(1) {
top: 18px;
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
-o-transform: rotate(135deg);
transform: rotate(135deg);
}
#nav-icon.open span:nth-child(2) {
opacity: 0;
left: -60px;
}
#nav-icon.open span:nth-child(3) {
top: 18px;
-webkit-transform: rotate(-135deg);
-moz-transform: rotate(-135deg);
-o-transform: rotate(-135deg);
transform: rotate(-135deg);
}
section {
background-color: grey;
border: solid 1px grey;
padding: 2%;
}
@media (max-width: 480px) {
.box-1,
.box-2,
.box-3 {
font-size: 60%;
}
#nav-icon span, #nav-icon3 span, #nav-icon4 span {
height: 7px;
width: 80%;
}
#nav-icon span:nth-child(1) {
top: 10px;
}
#nav-icon span:nth-child(2) {
top: 22px;
}
#nav-icon span:nth-child(3) {
top: 34px;
}
.box-2 {
border: solid 1px red;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header>
<nav>
<div class="box-1">
THE <SNIP>
</div>
<div class="box-2">
<div id="nav-icon">
<span></span>
<span></span>
<span></span>
</div>
</div>
<div class="box-3">
07429009478
</div>
</nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Contact</a></li>
</ul>
</header>
<section>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa facere dolor illum, voluptatum atque perspiciatis doloremque alias cupiditate a est sunt odio, repellat. Rerum et asperiores, necessitatibus aliquid minus, quia!</p>
</section>
需要帮助!
非常感谢!