Hit enter after type your search item

A pure CSS based accordion

What is CSS accordion?

The accordion is the way to present information that generally contains a title and its body contains the content. Normally, it fits the screen size of the users.

In the jQuery section, I showed how you can use the jQuery’s accordion plug-in with examples. It uses JavaScript underway and makes the process pretty easier for creating accordions.

In this tutorial, I will show you creating accordion by using pure CSS3 code. The accordion is super smooth and credit goes to the developer at GitHub website.

A demo of using jquery-like-accordion-by-css3 plug-in

The plug-in package includes a CSS file containing all the specifications for the accordion. Either use it in your external CSS or include that package CSS file or you may use it in <style> tag.

For the demo, I have used it inside the <style> tag:

CSS accordion

See online demo and code

The wrapper class specifies the color, width and margin etc. of the main container of accordion:


 

While single accordion specifies the properties for heading and content of the accordion:


 

There are many other classes that handle different elements. See the complete CSS and markup in the demo page.

Another style with border-radius and other properties

Following is another style of the CSS accordion where I changed a few other properties like background color and added border-radius for the main wrapper and accordion classes.

The color scheme is also changed. Have a look at the demo and code:

CSS accordion style

See online demo and code

You can see, the heading’s color is also changed as the mouse is brought in the title area of any accordion.

Another style of accordion with blockquote and background image

By using this simple script, look at another style where different CSS properties are changed to the reddish theme. You may use accordion for presenting customers feedback. As an accordion is opened, it will show customer quote with background image set.

In addition to changing the wrapper class, single-accordion, single-accordion:hover, etc. I also added a blockquote style. See the output and code below or in the demo page:

CSS accordion blockquot

See online demo and code

Following is the CSS used in above demo:


 

This markup section:


 

Just go ahead and modify the properties to match the theme of your website. This is really light-weight and smooth plug-in.

This div height required for enabling the sticky sidebar