I am trying to build a responsive navbar, unforunately the checkbox isn't working. I was following along a youtube video for the navbar. This is my HTML code:
body {
margin: 0;
padding: 0;
}
nav {
display: flex;
background-color: #457b9d;
justify-content: space-between;
align-items: center;
padding: 10px;
}
nav ul {
list-style: none;
display: flex;
margin: 0;
transition: font-size 0.5s ease-out;
font-size: 20px;
}
nav ul li {
margin: 10px;
color: white;
}
nav h2 {
color: white;
}
.fa {
padding: 5px;
font-size: 10px;
width: 15px;
text-align: center;
text-decoration: none;
margin: 5px 10px;
border-radius: 50px;
}
.fa-facebook {
background: white;
color: #3B5998;
}
.fa-instagram {
background: white;
color: #125688;
}
#social {
display: flex;
flex-direction: row;
align-items: center;
}
nav .menu-btn i {
color: white;
font-size: 22px;
margin: 0px 10px;
cursor: pointer;
display: none;
}
#click {
display: none;
}
@media (max-width:940px) {
nav .menu-btn i {
display: block;
}
#click:checked~nav .menu-btn i::before {
content: "\f00d";
}
nav ul {
position: fixed;
top: 80px;
left: -100%;
background-color: #457b9d;
height: 100vh;
width: 100%;
display: block;
text-align: center;
font-size: 30px;
padding: 0;
}
#check:checked~ul {
left: 0%;
}
nav ul li {
margin: 40px 0;
}
}
<meta charset="UTF-8">
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<nav>
<h2>TRT</h2>
<ul>
<li>About Us</li>
<li>Products</li>
<li>Facilities</li>
<li>Contact Us</li>
</ul>
<div id="social">
<a href="#" class="fa fa-facebook"></a>
<a href="#" class="fa fa-instagram"></a>
<input type="checkbox" id="click">
<label for="click" class="menu-btn">
<i class="fas fa-bars"></i>
</label>
</div>
</nav>
I don't know how to fix it as I am very new to web development. I did search up some solution but none of them worked. Please help.
Aucun commentaire:
Enregistrer un commentaire