Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* index.html */
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie-edge">
- <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
- <link rel="stylesheet" href="style.css">
- <title>My Page</title>
- </head>
- <body>
- <nav>
- <div class="logo">
- <h1>The Nav</h1>
- </div>
- <ul class="nav-links">
- <li>
- <a href="#">Home</a>
- </li>
- <li>
- <a href="#">About</a>
- </li>
- <li>
- <a href="#">Work</a>
- </li>
- <li>
- <a href="#">Projects</a>
- </li>
- </ul>
- <div class="burger">
- <div class="line1"></div>
- <div class="line2"></div>
- <div class="line3"></div>
- </div>
- </nav>
- <script src="script.js"></script>
- </body>
- </html>
- /* style.css */
- *{/*It is used to select all the tags of the HTML file to apply few common properties to it*/
- margin: 0px;
- padding: 0px;
- box-sizing: border-box;
- }
- nav{
- display: flex;
- justify-content: space-around;
- align-items: center;
- min-height: 8vh;
- background-color: blue;
- font-family: 'Roboto', sans-serif;
- }
- .logo{
- color: white;
- text-transform: uppercase;
- letter-spacing: 5px;
- font-size: 20px;
- }
- .nav-links{
- display: flex;
- justify-content: space-around;
- width: 30%;
- }
- .nav-links a{
- color: white;
- text-decoration: none;
- letter-spacing: 3px;
- font-weight: bold;
- font-size: 14px;
- }
- .nav-links li {
- list-style: none;
- }
- .burger{
- display: none;
- cursor: pointer;
- }
- .burger div{
- width: 25px;
- height: 3px;
- background-color: white;
- margin: 5px;
- }
- @media screen and (max-width: 1024px){/*don't forget to take a look at px resolution*/
- .nav-links{
- width: 60%;
- }
- }
- @media screen and (max-width: 768px){
- body{
- overflow-x : hidden;
- }
- .nav-links{
- position: absolute;
- right: 0px;
- height: 92vh;
- top: 8vh;
- background-color: blue;
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 50%;
- transform: translateX(100%);
- transition: transform 0.5s ease-in ;
- }
- .nav-links li{
- opacity: 0;
- }
- .burger{
- display: block;
- }
- }
- .nav-active{
- transform: translateX(0%);
- }
- /* script.js */
- consta navSlide = () => {
- const burger = document.querySelector('.burger');
- const nav = document.querySelector('.nav-links');
- burger.addEventListener('click', () => {
- nav.classList.toggle('nav-active');
- });
- }
- navSlide();/* min 22 - https://www.youtube.com/watch?v=gXkqy0b4M5g&t=902s */
RAW Paste Data