Reputation: 15
Hey guys so I'm trying to make a fullscreen navigation bar with vertically and horizontally centered content, I achieved my goal and created everything easily, but there's one problem.. I wrote all the code but it seems that the jquery code is not working, I checked with chrome's developers tool and there's no class added to the tag that I want it to be added to. Here's my code
<div class="toggle"><a><i class="fa fa-bars" aria-hidden="true"></i></a></div>
<div class="menu">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Students</a></li>
<li><a href="#">Contact</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Other
</a>
<div class="dropdown-menu dropdown-menu-down" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="comingsoon.html">States</a>
<a class="dropdown-item" href="memes/memes.html">Memes</a>
</div>
</li>
</ul>
</div>
<script
src="https://code.jquery.com/jquery-3.4.1.js"
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
crossorigin="anonymous"></script>
.toggle {
position: fixed;
top: 40px;
left: 40px;
z-index: 2;
}
.toggle a {
text-decoration: none;
color: #262626;
font-size: 24px;
cursor: pointer;
}
.menu {
margin: 0;
padding: 0;
position: fixed;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: #fff;
z-index: 1;
transition: .5s;
}
.menu ul {
margin: 0;
padding: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.menu ul li {
list-style: none;
}
.menu ul li a {
padding: 10px;
display: inline-block;
font-family:;
font-size: 2em;
text-decoration: none;
text-transform: uppercase;
color: #262626;
text-align: center;
}
.menu.active {
left: 0;
overflow: auto;
}
<script type="text-javascript">
$(document).ready(function() {
$('.toggle a').click(function() {
$('.menu').toggleClass('active');
})
})
</script>
Upvotes: 0
Views: 63
Reputation: 405
your code is fine, you need to replace only "text-javascript" to "text/javascript"
Upvotes: 2