Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • jQuery
  • AngularJS
  • ReactJS
  • Next.js
  • React Native
  • NodeJS
  • Express.js
  • MongoDB
  • MERN Stack
  • PHP
  • WordPress
  • Bootstrap
  • Tailwind
  • CSS Frameworks
  • JS Frameworks
  • Web Development
Open In App
Next Article:
How to create animated banner links using HTML and CSS?
Next article icon

Creating an Animated Side Navbar using HTML and CSS

Last Updated : 30 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we will learn about creating an Animation side Navbar using HTML and CSS, Almost every website contains a side navigation bar. By using a side navigation bar, users can easily navigate to the other pages of the website and if the navigation bar is animated it looks attractive and catches the attention of the viewer. In this article, we are going to see the basic code for the creation of a side navigation bar. The code contains HTML code and CSS.

Approach: The approach is to use the nth-child property to animate the hover effect.

HTML Code: In this section, we are going to create a basic structure of a side navigation bar that contains text, images, icons, etc. by using an unordered list.

CSS Code: In this section, we are giving basic styles to the text, icons, and images that we use in HTML code, and we are using the nth-child property to move our hover effect in short and animate the hover effect.

Example: Here is the demonstration of the above-explained approach.

HTML
<!DOCTYPE html> <html> <head>     <meta charset="utf-8">     <meta name="viewport" content=         "width=device-width,initial-scale=1.0">     <title>side navigation bar</title>     <script src= "https://kit.fontawesome.com/bba3432f3f.js"                crossorigin="anonymous"></script>     <link rel="stylesheet" href="style.css"> </head>  <body>     <div class="header">         <div class="side-nav">             <a href="#" class="logo">                 <img src="logo.png" class="logo-img">             </a>             <ul class="nav-links">                 <li><a href="#">                         <i class="fa-solid fa-house-user"></i>                         <p>Dashboard</p>                     </a>                 </li>                 <li><a href="#">                         <i class="fa-solid fa-comment-dots"></i>                         <p>Message</p>                     </a>                 </li>                 <li><a href="#">                         <i class="fa-solid fa-user"></i>                         <p>users</p>                     </a>                 </li>                 <li><a href="#">                         <i class="fa-solid fa-box-open"></i>                         <p>Rewards</p>                     </a>                 </li>                 <li><a href="#">                         <i class="fa-solid fa-chart-pie"></i>                         <p>Report</p>                     </a>                 </li>                 <li><a href="#">                         <i class="fa-solid fa-screwdriver-wrench"></i>                         <p>Setting</p>                     </a>                 </li>                 <div class="active"></div>             </ul>         </div>     </div> </body> </html> 
CSS
* {     margin: 0;     padding: 0;     box-sizing: border-box;     font-family: "Poppins", sans-serif; }  .header {     width: 100%;     height: 100vh;     background: #ccffff; }  .side-nav {     width: 250px;     height: 100%;     background: #00ff00;     position: fixed;     top: 0;     left: 0;     padding: 20px 30px; }  .logo {     display: block;     margin-bottom: 130px; }  .logo-img {     width: 170px;     margin-top: 20px; }  .nav-links {     list-style: none;     position: relative; }  .nav-links li {     padding: 10px 0; }  .nav-links li a {     color: #000000;     text-decoration: none;     padding: 10px 14px;     display: flex;     align-items: center; }  .nav-links li a i {     font-size: 22px;     margin-right: 20px; }  .active {     background: #000000;     width: 100%;     height: 47px;     position: absolute;     left: 0;     top: 2.6%;     z-index: -1;     border-radius: 6px;     box-shadow: 0 5px 10px rgba(255, 255, 255, 0.4);     display: none;     transition: top 0.5s; }  .nav-links li:hover a {     color: #fff;     transition: 0.3s; }  .nav-links li:hover~.active {     display: block; }  .nav-links li:nth-child(1):hover~.active {     top: 2.6%; }  .nav-links li:nth-child(2):hover~.active {     top: 19.2%; }  .nav-links li:nth-child(3):hover~.active {     top: 35.8%; }  .nav-links li:nth-child(4):hover~.active {     top: 52.4%; }  .nav-links li:nth-child(5):hover~.active {     top: 69%; }  .nav-links li:nth-child(6):hover~.active {     top: 85.6%; } 

Output:

https://media.geeksforgeeks.org/wp-content/uploads/20240725150015/ezgifcomgifmaker.mp4


Next Article
How to create animated banner links using HTML and CSS?

A

akshaybotre203
Improve
Article Tags :
  • Web Technologies
  • Web Templates

Similar Reads

  • How to Create an Animated Search Box using HTML and CSS ?
    The task is to create an Animated Search Box using HTML and CSS. The search bar is one of the most important components of the website. Basically, it is used for connecting people with websites. In the face of complicated web content, users express their needs by searching keywords, expecting to obt
    2 min read
  • How to create Animated Blur Navbar using CSS?
    The Navbar is the main component of any website through which the user can navigate through all the components and sections of a site. That's why it is really important to have a well-designed navigation bar or menu. So today we will be looking at a navbar in which all the elements get blur except t
    2 min read
  • Create an Icon Bar using HTML and CSS
    This article provides a complete idea of how to create an Icon Bar using HTML and CSS. HTML is used to design the structure, and CSS applies styles to the elements to make the user interface (UI) attractive. To add the Icons, we use the Font Awesome icons CDN link in the head section, and add the ic
    2 min read
  • How to create Animated bars using HTML and CSS?
    Dancing bars are one of the classical components that are used in making a good looking website. They are very simple to implement and can be used as a loader or an animation while recording sound. Approach: The approach is to use unordered list to create bars and then animate them using keyframes.
    2 min read
  • How to create animated banner links using HTML and CSS?
    Links are one of the most important parts of any component that is used in website making. Almost every component had some form of links in it. A common example is a menu/nav-bar. All we see is some button like home, about, etc. but under the hood they all are links. Sometimes there comes a situatio
    2 min read
  • Design a Video Slide Animation Effect using HTML CSS and JavaScript
    Nowadays, Video Slide animations are very popular. In this article, we will see how to make Video Slide Animation using HTML, CSS, and JavaScript on any webpage. Below are the two steps on how to do it. It will help the beginner to build some awesome Video Slide animations using HTML, CSS, and JS by
    4 min read
  • Create a Tooltip Button Animation using HTML and CSS
    The Tooltip Animation can be implemented to display additional information about a user or profile when hovering over a designated button or icon. Animations, like tooltips and button animations, add a layer of interactivity to the user interface, making the experience more engaging and enjoyable. P
    4 min read
  • Create a Fixed Sidebar using HTML and CSS
    A fixed sidebar (side navigation bar) is a common layout pattern where the sidebar remains fixed on the screen while the rest of the content scrolls. This article will create a fixed sidebar using HTML and CSS. HTML creates the structure layout, and CSS applies styles to the elements. First, we crea
    4 min read
  • Create A Bottom Navigation Menu using HTML and CSS
    This article will show you how to create a bottom navigation menu using HTML and CSS. The navigation menu is an essential component in modern web design. It allows users to navigate through a website easily. Here, we use HTML to create the structure of the Bottom Navigation menu, and CSS add styles
    2 min read
  • How to create a progress bar animation using HTML and CSS ?
    In this mini Web Development project we will utilize CSS animations and create a progress bar using them. The progress bar will start from zero and go to a certain extent as we want. The progress bar is basically showing the expertise of a programmer in different languages in animated form. Prerequi
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences