I’m trying to make a basic responsive navbar which under certain pixels will display a hamburger menu instead of the navlinks. However, the @media doesn’t seem to do anything at all. I really thought I did everything right so I have no idea what is wrong here?
HTML code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> -->
<title>Site Title</title>
<!-- <meta name="description" content=""> -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./styles.css">
<script></script>
</head>
<body>
<nav class="navbar">
<div class="brand-title">Brand Name</div>
<a href="#" class="toggle-button">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</a>
<div class="nav-links">
<ul>
<li><a href="#"></a>Home</li>
<li><a href="#"></a>About</li>
<li><a href="#"></a>Contact</li>
</ul>
</div>
</nav>
</body>
</html>
CSS Code
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #333;
color: white;
}
.brand-title {
font-size: 1.5rem;
margin: .5rem;
}
.nav-links ul {
margin: 0;
padding: 0;
display: flex;
}
.nav-links li {
list-style: none;
padding: 1rem;
}
.nav-links li a {
text-decoration: none;
color: white;
display: block;
}
.nav-links li:hover {
background-color: #555;
}
.toggle-button {
position: absolute;
top: .75rem;
right: 1rem;
display: none;
flex-direction: column;
justify-content: space-between;
width: 30px;
height: 21px;
}
.toggle-button .bar {
height: 3px;
width: 100%;
background-color: white;
border-radius: 10px;
}
@media (max-width: 800x){
.toggle-button {
display: flex;
}
.nav-links {
display: none;
}
}