Create Responsive Menu With HTML And CSS Only ( No JavaScript )
HTML Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Responsive Menu</title> <link rel="stylesheet" href="style.css"> <!-- Font Awesome --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> </head> <body> <nav> <input type="checkbox" id="menu-check"> <label for="menu-check"> <i class="fa fa-bars" id="menu-open"></i> <i class="fa fa-times" id="menu-close"></i> </label> <h1 class="logo">Venom</h1> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Work</a></li> <li><a href="#">Portfolio</a></li> <li><a href="#">Contact</a></li> </ul> </nav> <!-- Background --> <section></section> </body> </html>
CSS Code/* Google Fonts */ @import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,200;1,300;1,400;1,500;1,600;1,700;1,800&display=swap"); * { margin: 0; padding: 0; font-family: "Poppins", sans-serif; list-style: none; text-decoration: none; } nav { height: 60px; background: #65fc; } .logo { position: absolute; width: 200px; left: 6%; top: 12px; color: #fff; text-transform: uppercase; } nav ul { float: right; margin-right: 25px; } nav ul li { display: inline-block; line-height: 60px; margin: 0 15px; } nav ul li a { position: relative; padding: 5px 0; color: #fff; font-size: 16px; font-weight: 600; text-transform: uppercase; } label #menu-open, #menu-close { font-size: 30px; color: #fff; float: right; line-height: 60px; margin-right: 30px; cursor: pointer; display: none; } #menu-check { display: none; } section { width: 100%; height: 95vh; background: url(background.jpg); background-repeat: no-repeat; background-size: cover; background-position: center; } /* Making Responsive */ @media (max-width: 880px) { label #menu-open { display: block; } nav ul { position: fixed; width: 100%; height: 100vh; background: #65fc; border-top: 1px solid #444; top: 60px; left: -100%; text-align: center; transition: 0.5s; z-index: 10; } nav ul li { display: block; margin: 65px 0; line-height: 30px; } nav ul li a { font-size: 20px; } #menu-check:checked ~ ul { left: 0; } #menu-check:checked ~ label #menu-open { display: none; } #menu-check:checked ~ label #menu-close { display: block; } }
Download Files:
Thanks so much for your sharing๐คฉ๐๐ช