How to create a Hoverable Sidenav with CSS?

A hoverable sidenav is a navigation menu that slides out from the side of the page when hovered. This creates an interactive navigation experience while saving screen space.

Syntax

selector {
    position: fixed;
    left: -width;
    transition: duration;
}

selector:hover {
    left: 0;
}

Example

The following example creates a hoverable side navigation with multiple links that slide out on hover −

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hoverable Sidenav</title>
<style>
    nav a {
        position: fixed;
        left: -120px;
        transition: 0.3s;
        padding: 10px;
        width: 140px;
        text-decoration: none;
        font-size: 20px;
        color: black;
        font-weight: bold;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        border-radius: 0 8px 8px 0;
    }
    
    nav a:hover {
        left: 0;
    }
    
    #Info {
        top: 20px;
        background-color: #6de2f7;
    }
    
    #Social {
        top: 80px;
        background-color: #71fc71;
    }
    
    #Address {
        top: 140px;
        background-color: #c4f553;
    }
    
    #Home {
        top: 200px;
        background-color: rgb(225, 115, 240);
    }
</style>
</head>
<body>
    <nav>
        <a href="#" id="Info">More Info</a>
        <a href="#" id="Social">Social Links</a>
        <a href="#" id="Address">Address</a>
        <a href="#" id="Home">Home</a>
    </nav>
</body>
</html>
Four colorful navigation tabs appear on the left edge of the screen. When you hover over any tab, it smoothly slides out revealing the full text. Each tab has a different color: Info (light blue), Social (green), Address (yellow-green), and Home (purple).

Key Properties

Property Purpose
position: fixed Keeps the navigation in place while scrolling
left: -120px Hides most of the nav off-screen initially
transition: 0.3s Adds smooth sliding animation
left: 0 on hover Slides the navigation into view

Conclusion

The hoverable sidenav uses CSS positioning and transitions to create an interactive navigation menu. By combining position: fixed with negative left positioning and hover effects, you can create space-efficient navigation that appears on demand.

Updated on: 2026-03-15T14:16:07+05:30

433 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements