Skip to main content

Sidebar Menu Using Only HTML and CSS

This article shows you how to create sidebar menus using HTML and CSS code only. I have previously created many types of sidebars and navigation menubars using only HTML and CSS code so you can see those designs if you want.

 Side Menubar A popular web element is currently used in the sidebar along with menubars on various websites. Undoubtedly the side menu bar is much more attractive and for this, the quality and beauty of the website are greatly enhanced. Under normal circumstances, I have completely hidden the menu bar on the web page. 

There is a menu button that can be clicked to view the entire menu bar. There is also a cancel button which, when clicked, will completely hide the sidebar. In the sidebar, I have added links to various menu items, profile names, profile images, social media platforms.

 First I gave the profile image and below that, I gave the profile name. Then I added some menu items here and added icons to each menu item. Then I created the buttons of four social media platforms below all. In this case, I did not use any JavaScript code or any jQuery plugin. I only use HTML and CSS code I designed it. I used the checkbox to make this cancel and menu button work. If you have difficulty understanding then of course you can watch the demo below.


See the Pen Sidebar menu using html css by Raj Template (@RajTemplate) on CodePen.


Hope you find out from here how I created this simple sidebar menu. If you want to make it, you must follow the tutorial below. In the following tutorial, I have tried to explain to you how it is made by showing the possible results in each step.

1. Create the basic structure of the sidebar

First of all, I designed this sidebar, that is, its shape. In this case, I have used the width of the menu bar 250 px and the background # 020a0ee1.


<div class="sidebar">
 
</div>



.sidebar {
  position: absolute;
  width: 250px;
  background: #020a0ee1;
  transition: all 0.5s ease;
}




 2. Create profile images and titles

As you can see in the demo, this sidebar first contains the profile image and title. I have used the following HTML and CSS code to make it. I have used this image height and width of 120px and border radius 50%

Using border-radius, this image has a completely rounded shape. The header section differs from the sidebar in its background color. For this, I have used background color # 1a1c1dec here.


<header>
<img src="">
<p>Foolish Developer</p>
</header>



.sidebar header img {
  border-radius: 50%;
  width: 120px;
  height: 120px;
}
.sidebar header {
  font-size: 22px;
  color: #fff;
  text-align: center;
  line-height: 30px;
  background: #1a1c1dec;
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  user-select: none;
}


3. Create the necessary menu items

Now I will add various links to this menu bar. To make the icons work here, you must add a font awesome CDN link to your HTML file. I used the font size of these menu items as 18 px. I have given Howie effect on these items. When you click on those menu items or move the mouse, a blue border will be created on the left side.


<ul>
    <li><a href="#"><i class="fa fa-qrcode"></i>Dashboard</a></li>
    <li><a href="#"><i class="fa fa-link"></i>Shortcuts</a></li>
   
 
    <li><a href="#"><i class="fa fa-book"></i>Event</a></li>
    <li><a href="#"><i class="fa fa-question-circle"></i>About</a></li>
    <li><a href="#"><i class="fas fa-desktop"></i>Service</a></li>
    <li><a href="#"><i class="fas fa-user-shield"></i>Contact</a></li>
</ul>



.sidebar ul a {
  display: block;
  height: 100%;
  width: 100%;
  line-height: 65px;
  font-size: 18px;
  color: #fff;
  padding-left: 40px;
  box-sizing: border-box;
  border-top: 1px solid rgba(80, 80, 80, 0.329);
  border-bottom: 1px solid black;
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  transition: 0.4s;
}
.sidebar ul a i {
  margin-right: 16px;
}
/* hover effect */
ul li:hover a {
  border-left: 10px solid rgb(50, 200, 238);
}

4. Create social media buttons

This time we will add links to various social media platforms. Here I have basically used the links on four social media.


   <li>
      <div class="social-links">
        <a href="#"><i class="fab fa-facebook"></i></a>
        <a href="#"><i class="fab fa-youtube"></i></a>
        <a href="#"><i class="fab fa-twitter"></i></a>
        <a href="#"><i class="fab fa-whatsapp"></i></a>
        
      </div>
   </li>



.social-links i {
  padding: 10px;
  margin-left: 16px;
  margin-top: 10px;
  color: #fff;
  background: #05071aa1;
  font-size: 20px;
}
/* icons hover effect */
.social-links i:hover {
  color: #67fd41;
}

5. Add menu button and cancel button

This time we will create the Cancel and Menu buttons using the checkboxes. I will execute that menu bar using the following CSS codes. first I left the sidebar 250 px(left: -250px;). This will completely hide the sidebar. As I said before, this menu will be completely hidden under normal conditions. A small menu button will appear, clicking on which you will see the full bar. I checked: checked ~. I have left zero in the sidebar, that is, when I click on that menu button, it will be left zero. This means the menu bar can be seen.

Then I used the CSS code to determine the position of the Cancel and Menu buttons.


<input type="checkbox" id="check">

<label for="check">

<i class="fa fa-bars" id="btn"></i>
<i class="fa fa-times" id="cancle"></i>

</label>



.sidebar {
  left: -250px;
}
#check:checked ~ .sidebar {
  left: 0;
}
#check:checked ~ label #btn {
  left: 250px;
  opacity: 0;
  pointer-events: none;
}
#check:checked ~ label #cancle {
  left: 245px;
}
#check:checked ~ section {
  margin-left: 250px;
}


 Hopefully from this tutorial, you have learned how to create sidebar menus using only HTML and CSS code. If you like this tutorial, you can definitely see other menu designs made by me.





Comments

Popular Posts

Animated Progress Bar using Only HTML and CSS

Animated progress bar is mainly used in various business and personal web sites. css progress bar helps to organize your knowledge in a beautiful way. In this article, I am going to show you how to create an animated progress bar using only HTML and CSS code. I have made many other types of Progress Bar before but in that case, I have used JavaScript.  I have not used any JavaScript or external JavaScript library for this design. I created this Animated Progress Bar design using Pure HTML and CSS code. Skill bars are used on various websites to streamline the amount of experience, education, etc. with the help of animations. First of all, I have given the background-color: # 30336b of a web page. Then I made a small box here. I used four CSS Progress Bar in that box. The value of this bar will be zero when opening the page then gradually it will reach the pre-determined meaning. Video Tutorial of Pure CSS Progress Bar If you want to know how to make it better then you...

Responsive Navigation Menu Bar using only HTML & CSS

Responsive navigation menu bar plays an important role for every website. The navigation menu bar creates user satisfaction with the beauty of the website. The user needs a responsive navbar so that he can easily find the topic of his choice.  I have designed many more types of menubars before. But in that case, I used JavaScript code to execute the menu button. I have not used any JavaScript or external JavaScript library for this design. I have created this Responsive Navigation menu bar using pure CSS and HTML code. I only used CSS code to make it responsive. I have made it responsive using only the  @media function of CSS code. Here I have basically used a logo and used five menu items . I have used the hover effect on the menu links. The background color will change when you click on those items or move the mouse. Video Tutorial of Responsive Navigation Menu Bar You can watch the video tutorial below to know how it works and how to make it. How T...

Automatic Image Slider using Only HTML & CSS

In this article, I am going to show you how to create an automatic image slider using only HTML and CSS code. We know that an image slider is a simple web element that is used to organize different images of the website in one place.  There are different types of image sliders and the most automatic image slider is used. This type of slider is mainly used in the hero section of the homepage of various websites. In addition, different types of services or portfolio websites are used to decorate the images of many types of projects.  Basically, this type of design has no navigation buttons which means there is no way to change the image manually. The images here will continue to change automatically from time to time. You can set this time in advance.  First of all, I set the background of a web page to black. Then I arranged all the images nicely there. In this case, I did not use any JavaScript code . It was created using effects in the animation of css3. ...

3D Image Slideshow using Only HTML and CSS

3D Image Slideshow is a type of image gallery that is currently used on a variety of websites. It helps to keep many types of images neatly arranged together. This not only enhances the beauty of the website but also user satisfaction.  I have already created many types of image sliders and image galleries but it is a little different. Basically, we use JQuery or JavaScript to change the image in other designs. However, I did not use any JavaScript in this case. In this case, I made it using only HTML and css3 . Yeah Al that sounds pretty crap to me, Looks like css3 just got used to the modern animation effect .  In this case, no button was created to change the image. It tends to change from time to time by itself. This means that it is an automatic 3d image slider built with HTML and CSS code only. This 3D image slider is like a square box. At certain intervals, this box rotates from right to left. I have used four images around this box. When the box is rotated, e...