How to Create: Sidebar Navigation Buttons

Learn how to use CSS to create hoverable sidebar navigation buttons.

Try It Yourself

How to Create Hoverable Sidebar Navigation

Step 1 - Add HTML:

<div id="mySidenav" class="sidenav">
  <a href="#" id="about">About</a>
  <a href="#" id="blog">Blog</a>
  <a href="#" id="projects">Projects</a>
  <a href="#" id="contact">Contact</a>
</div>

Step 2 - Add CSS:

/* Set the style for links within the side navigation */
#mySidenav a {
  position: absolute; /* Position them relative to the browser window */
  left: -80px; /* Position them outside the screen */
  transition: 0.3s; /* Add a transition effect when hovered */
  padding: 15px; /* 15px padding */
  width: 100px; /* Set specific width */
  text-decoration: none; /* Remove underline */
  font-size: 20px; /* Increase font size */
  color: white; /* Set text color to white */
  border-radius: 0 5px 5px 0; /* rounded corners at the top right and bottom right */
}
#mySidenav a:hover {
  left: 0; /* Make the element display as it should when hovered */
}
/* about link: 20px from the top, green background */
#about {
  top: 20px;
  background-color: #04AA6D;
}
#blog {
  top: 80px;
  background-color: #2196F3; /* blue */
}
#projects {
  top: 140px;
  background-color: #f44336; /* red */
}
#contact {
  top: 200px;
  background-color: #555 /* light black */
}

Try It Yourself

Related Pages

Tutorial:CSS Navigation Bar