How to Create Hoverable Side Navigation Buttons with CSS

Navigation buttons are an essential part of any website.

They allow visitors to easily access different pages and content on your site.

While traditional navigation buttons are static and do not change appearance when a user hovers over them, hoverable side navigation buttons provide a more interactive and visually appealing experience.

In this tutorial, we’ll walk you through how to create hoverable side navigation buttons using CSS.


HTML Structure

To get started, let’s create the HTML structure for our navigation buttons.

We’ll use an unordered list with list items for each button. Each list item will contain a link that will take the user to a different page on your website.

<ul class="side-nav">
  <li><a href="#">Home</a></li>
  <li><a href="#">About</a></li>
  <li><a href="#">Services</a></li>
  <li><a href="#">Contact</a></li>
</ul>

CSS Styles

Next, let’s add some basic styles to our navigation buttons using CSS.

We’ll start by giving the unordered list a width and height, setting the list items to display as inline blocks, and giving them a padding.

.side-nav {
width: 200px;
height: 100%;
list-style: none;
position: fixed;
top: 60px;
left: 0;
background-color: #fff;
padding: 20px;
}

.side-nav li {
display: inline-block;
width: 100%;
margin-bottom: 10px;
}

.side-nav a {
display: block;
padding: 10px;
color: #333;
text-decoration: none;
}

Hover Effects

Now, let’s add some hover effects to our navigation buttons.

When a user hovers over a button, we’ll change the background color and the color of the text.

.side-nav a:hover {
  background-color: #f1f1f1;
  color: #000;
}

Conclusion

And that’s it! With just a few lines of HTML and CSS, you now have a fully functional and visually appealing set of hoverable side navigation buttons for your website.

With a little customization, you can make these buttons match the style and branding of your site.