I've been attempting to optimize this navigation bar for mobile devices, exploring various methods like @media queries and the hamburger menu technique through resources like YouTube. However, none of these approaches have proven effective so far. It seems that I may need to completely rewrite the HTML structure to align with the recommended practices.
Below is my original code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Waverly Farm: Home</title>
<link href="style.css" rel="stylesheet"/>
</head>
<body>
<header class = "header">
<div class = "logo">Waverely Farm</div>
<nav class = "navbar">
<a href ="index.html">Home</a>
<a href ="about_us.html">About Us</a>
<a href ="services.html">Services</a>
<a href ="shop.html">Shop</a>
<a href ="contactus.html">Contact Us</a>
</nav>
</header>
</body>
</html>
Although I attempted using @media queries, I'm uncertain about leveraging it effectively for this specific type of navigation bar.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}
.header{
position: fixed;
top: 0;
left: 0;
width: 100%;
padding: 20px 100px;
background-color: aquamarine;
display:flex;
justify-content: space-between;
align-items: center;
z-index: 100;
}
.logo{
font-size: 32px;
color: #fff;
text-decoration: none;
font-weight: 700;
}
.navbar a{
position: relative;
font-size: 18px;
color: #fff;
font-weight: 400;
text-decoration: none;
margin-left: 40px;
}
.navbar a::before{
content:'';
position: absolute;
top: 100%;
left: 0;
width: 0;
height: 2px;
background: #fff;
transition: .3s;
}
.navbar a:hover::before{
width: 100%;
}