CSS Only Vertical Accordion Sidebar Menu

In this tutorial we will see how to create a CSS Vertical Accordion Menu. For this we have used pure CSS, this is a vertical accordion menu with toggle effect.

HTML Code

Take a look at the HTML code given below.

<!DOCTYPE html>
<html lang="">
<head>
 <meta charset="utf-8">
 <title>CSS Only Vertical Accordion Menu</title>
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css">
 <link href="style.css" rel="stylesheet">
</head>
<body>
 <nav class="menu">
   <ul>
	<input type="radio" name="menu" id="dashboard" checked>
    <li>
    <label for="dashboard" class="title">
    <i class="fa fa-dashboard"></i>Dashboard
    </label>
	<a href="#">Projects</a>
    <a href="#">Tools</a>
    <a href="#">Analytics</a>
  </li>
  <input type="radio" name="menu" id="tasks">
	<li>
	<label for="tasks" class="title">
     <i class="fa fa-tasks"></i>Tasks
    </label>
	<a href="#">HTML</a>
    <a href="#">CSS</a>
    <a href="#">JavaScript</a>
   </li>
  <input type="radio" name="menu" id="profile">
   <li>
    <label for="profile" class="title">
    <i class="fa fa-user"></i>Profile
    </label>
	<a href="#">Messages</a>
	<a href="#">Settings</a>
    <a href="#">Logout</a>
   </li>
  </ul>
 </nav>
 <div class="main">
  <h1>Heading</h1>
  <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
   </div>
</body>

CSS Code

CSS code is given below.

<style>
*{
    margin: 0;
	padding: 0;
    font-family: monospace;
    box-sizing: border-box;
}
nav { 
	width: 20%;
    height: 100vh;
	background-color: #111;
    float: left;
}
.title{
    background: linear-gradient(#000, #222);
	font-size: 14px;
	display: block;
	padding: 10px 15px;
	cursor: pointer;
    transition: all .25s;
	color: #FFF;
}
ul li{
	background-color: #111;
	height: 35px;
	overflow: hidden;
	transition: all .3s;
	font-weight: bold;	
}
a{
	font-size: 12px;
	text-decoration: none;
	display: block;
	padding: 10px 25px;
	transition: all .25s;
	color: #FFF;
}
a:hover {
	background-color: #333;
    box-shadow: inset 5px 0px 0px 0px #f00;
}
.title:hover {
	text-shadow: 0px 0px 10px #fff;
}
input[type="radio"] {
	display: none;
}
#dashboard:checked + li, #tasks:checked + li, #profile:checked + li {
	height: 140px;
}
i {
	margin-right: 10px;
}
.main {
    width: 80%;
    padding: 10px;
    float: right;
}
</style>           

Video Tutorial

Watch our video tutorial on CSS Only Vertical Accordion Menu.

Social Media Menu with Popup Tooltip using HTML and CSS Horizontal Navigation Menu with HTML and CSS Responsive Sidebar Menu with CSS and JavaScript Cool CSS Button with Hover Animation Pure CSS Custom Radio Buttons Custom Emoji Radio Buttons with CSS Color Picker Design with HTML CSS and JavaScript Custom Radio Buttons with CSS Engraved HTML Buttons With CSS Neumorphic Buttons Design with CSS Cool Profile Card Design with HTML CSS Neumorphic Search Bar Design with HTML and CSS Simple Login Form with Placeholder Animation Pure CSS Button with Folded Corner Background Color Change Slider with HTML CSS and JavaScript 404 Page Not Found Template Design with HTML and CSS Movies Blog Card Design with HTML and CSS Simple CSS Border Animation with before and after Selector Custom Social Select Dropdown Menu with CSS and JavaScript Facebook Offline and Online Notification with CSS and JS New Year 2022 Text Animation with CSS and JS Change Placeholder Color using CSS Custom Select Tag DropDown with CSS and JavaScript Simple Price Range Slider With HTML CSS and JavaScript Profile Card With Hover Effect using HTML and CSS Circle With Two Colors using CSS Simple FAQ Accordion With HTML CSS and JavaScript