How to create an Animated Navigation Menu using HTML & CSS – Solution: Animated Navigation Menu using HTML & CSS with source code, demo, and also how you can execute full program easily. To complete the program you need to follow those steps given bellow
Live Demo
Also Helpful –
Responsive Header Navigation Menu
Animated Navigation Menu using HTML & CSS
Description
Back to coding, To complete this program with debugging free code you have to create two files. The first file is to HTML and the second file gonna be CSS for the style part,
index.html
Create an HTML file named ‘index.html‘ and put those codes given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<!-- Coding Debugging (https://codingdebugging.com) --> <!DOCTYPE html> <html> <head> <title>Animated Navigation Menu - Coding Debugging</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- My Stylesheet --> <link rel="stylesheet" href="style.css"> </head> <body> <div class="navigation"> <input type="checkbox" name=""> <span></span> <span></span> <ul class="menu"> <li><a href="#">Home</a></li> <li><a href="#">Blog</a></li> <li><a href="#">Tools</a></li> <li><a href="#">Contact</a></li> <li><a href="#">About</a></li> </ul> </div> </body> </html> |
style.css
Create a CSS file named ‘style.css‘ and put those codes given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
@import url('https://fonts.googleapis.com/css?family=Poppins:100,200,300,400,500,600,700'); body { margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; min-height: 100vh; background:linear-gradient(to right, #993cd7, #b42727); font-family: 'Poppins', sans-serif; } .navigation { position: relative; display: flex; justify-content: center; align-items: center; background: #fff; padding: 20px; transition: 0.5s; border-radius: 4px; overflow: hidden; box-shadow: 0 8px 15px rgba(0,0,0,.2); } .menu { margin: 0; padding: 0; width: 0; overflow: hidden; display: flex; transition: 0.5s; } .menu li { list-style: none; margin: 0 10px; } .menu li a { text-decoration: none; color: #666; text-transform: uppercase; font-weight: 600; transition: 0.5s; display: inline-block; } .menu li a:hover { color: #42a8f9; } .navigation input { width: 40px; height: 40px; cursor: pointer; opacity: 0; } .navigation span { position: absolute; left: 26px; width: 32px; height: 4px; background: #666; pointer-events: none; transition: 0.5s; } .navigation input:checked ~ span { background: #f97; } .navigation span:nth-child(2) { transform: translateY(-8px); } .navigation input:checked ~ span:nth-child(2) { transform: translateY(0) rotate(45deg); } .navigation span:nth-child(3) { transform: translateY(8px); } .navigation input:checked ~ span:nth-child(3) { transform: translateY(0) rotate(-45deg); } .navigation input:checked ~ .menu { width: 400px; } |
Thank you for visiting!
We appreciate you for your precious time. I hope you are learn something from here! If you have any queries about this coding comment down below we will reply ASAP.
Keep coding, Keep debugging!