Yogesh Chauhan's Blog

How to create a sidebar using pure CSS?

in CSS on April 2, 2021

Sidebar can be easily created using a script or script framework but it can be created using pure CSS as well.

I am going to use the same concept as switching themes using pure CSS. We’re going to have a hidden checkbox input HTML element and then based on the :checked selector we can add add or remove the style.

Let’s dive in and add the input element and keep it hidden. Also, let’s add the main section that will have all the contents and a button inside to toggle the sidebar.

Now, let’s add the sidebar content and keep it outside of the main section area by positioning it fixed. We’ll keep the style a bit different for the sidebar close button.

Finally, add the style for the :checked selector.

How to move that sidebar to bottom?

Just change the position of the sidebar like this:


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS? #Aug 1 What is Zdog? #Aug 1 How to add before after image effect using pure CSS? #Jul 31 Add animation to your skills bar using CSS #Jul 31 Use SwiperJS to create mobile touch sliders fast
You might also like these
How to Recognize an Array in JavaScript?JavaScriptTackle Accessibility in React with JSXReactWhat Is a Graph Database?MiscellaneousHow to add and remove list items using JavaScript?JavaScriptThe SQL UNION OperatorSQL/MySQLHow to add recaptcha version 3 to PHP website?PHPFull and Partial ROLLUP in Postgresql with ExamplesPostgres3 Common Usability Mistakes In Web DesignUI/UXContainers 101: What are containers?MiscellaneousHow to import a CSS file using PHP code and not HTML code?PHPHow to add Lifecycle Methods to a Class in React?ReactHow to solve “framework not found” error in Swift?Swift