I am coding a website for my high school, and I am using a hamburger navigation for the website. When the website is shrunk to mobile mode, the hamburger loads and everything works. But if I close the hamburger and bring the website back to Desktop mode, the navigation is gone, because the <ul>
tag is changed to display="none";
and I can't find a way to fix it.
$(document).ready(function() {
$(".hamburger").click(function() {
$("nav > ul").slideToggle(800);
})
});
nav {
width: 100%;
min-height: 50px;
float: left;
font-family: "TT Pines Bold Italic DEMO";
font-size: 18px;
background: #444;
text-align: center;
display: block;
top: 0;
position: fixed;
z-index: 10;
}
nav>ul {
padding: 0;
list-style: none;
overflow: hidden;
margin: 0;
}
nav>ul>li {
display: inline;
line-height: 50px;
}
nav>ul>li>a {
text-decoration: none;
color: #fff;
padding: 25px 17px;
text-transform: uppercase;
font-size: 20px;
letter-spacing: 2px;
font-family: 'Open Sans Condensed', sans-serif;
}
a:hover {
text-decoration: none;
color: #efb60b;
}
@media only screen and (max-width: 320px) {
nav {
width: 100%;
float: left;
text-align: center;
}
nav>ul {
margin-top: 50px;
padding: 0;
display: block;
list-style: none;
}
nav>ul>li,
nav>ul>li>a {
line-height: 50px;
display: list-item;
margin-left: 0;
}
.hamburger {
padding: 20px;
display: block;
float: left;
text-align: center;
color: #fff;
font-size: 24px;
cursor: pointer;
}
}
@media only screen and (min-width: 320px) and (max-width: 768px) {
nav {
width: 100%;
float: left;
text-align: center;
}
nav>ul {
margin-top: 50px;
padding: 0;
display: block;
list-style: none;
}
nav>ul>li,
nav>ul>li>a {
line-height: 50px;
display: list-item;
margin-left: 0;
}
.hamburger {
padding: 20px;
display: block;
float: left;
text-align: center;
color: #fff;
font-size: 24px;
cursor: pointer;
}
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav>
<span class="hamburger"><i class="fa fa-bars" aria-hidden="false"></i></span>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="students.html">Students</a></li>
<li><a href="parents.html">Parents</a></li>
<li><a href="athletics.html">Athletics</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>