Animated Navigation Bar With Hover Effects Using HTML CSS & jQuery
Animated Navigation Bar With Hover Effects Using HTML CSS & jQuery
Animated Navigation Bar Using HTML CSS & jQuery
This Animated Navigation Bar is built using HTML, CSS, and jQuery to create a modern and interactive website navigation system. The design includes smooth hover animations, active menu highlighting, and dynamic class functionality that improves user interaction and navigation experience.
The project uses CSS transitions for animation effects and jQuery to add and remove active classes dynamically. The responsive layout ensures the navigation bar works perfectly across desktops, tablets, and mobile devices while maintaining a clean and professional appearance.
Steps to Create an Animated Navigation Bar
Follow these simple steps to build a responsive animated navbar:
- Create a project folder, for example,
animated-navigation-bar. - Inside the folder, create three files:
index.html,style.css, andscript.js. - Design the navigation bar structure using HTML.
- Add navigation links and organize the menu layout.
<header>
<div class="navbar">
<h2>The Providers</h2>
<ul class="list">
<li><a class="current" href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contacts</a></li>
<li><a href="#help">Help</a></li>
</ul>
</div>
</header>
<div id="about" style="margin-top: 650px;"><img style="width: 100%; height: 650px;" src="pic2.jpg"></div>
<div id="contact"><img style="width: 100%; height: 650px;" src="pic3.jpg"></div>
<div id="help"><img style="width: 100%; height: 650px;" src="pic4.jpg"></div>
Apply custom CSS styling to create hover effects and animations.
<style>
.current {
border-top: 2px solid orange;
}
body , html{
scroll-behavior: smooth;
}
body{
background-image: url(pic1.jpg);
font-family: cursive;
margin: 0;
padding: 0;
}
h2{
position: absolute;
color: white;
left: -60%;
top: -90%;
font-size: 30px;
}
.list{
position: absolute;
left: 27%;
top: 6%;
position:fixed;
}
.list li{
display: inline-block;
margin-left: 25px;
font-size: 25px;
color: white;
}
.list li a{
text-decoration: none;
color: white;
border-bottom: 2px solid orange;
border-bottom-width: 0;
transition: .5s ease-in-out;
}
.list li a:hover{
border-bottom: 3px solid orange;
border-bottom-width: 100%;
border-bottom-right-radius: 50%;
color: orange;
}
</style>
Use jQuery to add and remove active classes dynamically. Create smooth transitions and interactive navbar effects. Make the navigation bar fully responsive for desktops, tablets, and mobile devices. Save the files and open the project in a browser to test the final navigation menu.
<script type="text/javascript">
$( document ).ready(function() {
$('ul li a').click( function(){
if ( $(this).hasClass('current') ) {
$(this).removeClass('current');
} else {
$('li a.current').removeClass('current');
$(this).addClass('current');
}
});
});
</script>
