Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 7274

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 60k
Author
Asked: November 28, 20242024-11-28T02:17:09+00:00 2024-11-28T02:17:09+00:00

Simple Accordion Menu Using HTML And CSS Only

  • 60k

In this article, I am going to show you how to create an accordion menu using only simple HTML and CSS code. There are many ways to create an accordion menu. But the easiest way I am going to show this article. I created this menu using a very small amount of HTML and CSS code.

You can follow the video tutorial below to know more about this menu bar. From this video, you can learn step by step how this accordion menu bar was created.

You can download the source code required to make it completely free by clicking on the download button above. You can use the demo button above to watch the live demo.

If you want to know which programming code has been used to extend an element, you can follow the tutorial below. Below I have shown you how to create this menu bar in four steps.

Step 1: Add menus and text

The menus in this menu bar and the accompanying text have been created using the following programming codes. Here I am using six menus. You can add as many menus as you like and make changes.

 <!-- html code-->     <h1>Pure CSS Accordion Menu</h1>     <div class="accordionMenu">         <!-- 1st menu  -->         <input type="radio" name="trg1" id="acc1" checked="checked">         <label for="acc1">Quisquam Doloremeos</label>         <div class="content">             <div class="inner">                 It is a demo text.             </div>         </div>         <!-- 2nd menu -->         <input type="radio" name="trg1" id="acc2">         <label for="acc2">Fugiat esse oditanimi</label>         <div class="content">             <div class="inner">                 It is a demo text.             </div>         </div>         <!-- 3rd menu -->         <input type="radio" name="trg1" id="acc3">         <label for="acc3">Quibusdam adipisci</label>         <div class="content">             <div class="inner">                 It is a demo text.             </div>         </div>         <!-- 4th menu -->         <input type="radio" name="trg1" id="acc4">         <label for="acc4">Harum animi placeat</label>         <div class="content">             <div class="inner">                 It is a demo text.             </div>         </div>         <!-- 5th menu -->         <input type="radio" name="trg1" id="acc5">         <label for="acc5">Obcaecati Quibusdam</label>         <div class="content">             <div class="inner">                 It is a demo text.             </div>         </div>         <!-- 6th menu -->         <input type="radio" name="trg1" id="acc6">         <label for="acc6">Modi excepturi</label>         <div class="content">             <div class="inner">                 It is a demo text.             </div>         </div>     </div> 
Enter fullscreen mode Exit fullscreen mode

Step 2: Design the background and menus

Menu in this accordion menu using your own programming codes
These have been designed. Blue color has been used in the background of the menus.

/* now add css code */ body{     background: #ecf0f1;     font-family: 'source sans pro';     font-weight: 400; } h1{     font-size: 35px;     color: #2c97de;     text-align: center; } .accordionMenu{     width: 500px;     margin: 0 auto; } .accordionMenu input[type=radio]{     display: none; } .accordionMenu label{     display: block;     height: 50px;     line-height: 47px;     padding: 0 25px 0 10px;     background: #2c97de;     font-size: 18px;     color: #fff;     position: relative;     cursor: pointer;     border-bottom: 1px solid #e6e6e6; } 
Enter fullscreen mode Exit fullscreen mode

Step 3: Design and hide the contents of the menus

In general, the contents of this menu bar are hidden, only the menus are visible. The following programming code has been used to hide and design those.

.accordionMenu label::after{     display: block;     content: "";     width: 0;     height: 0;     border-style: solid;     border-width: 5px 0 5px 10px;     border-color: transparent transparent transparent #ffffff;     position: absolute;     right: 10px;     top: 20px;     z-index: 10;     -webkit-transition: all 0.3s ease-in-out;     -moz-transition: all 0.3s ease-in-out;     -ms-transition:all 0.3s ease-in-out;     -o-transition: all 0.3s ease-in-out;     transition: all 0.3s ease-in-out; } .accordionMenu .content{     max-height: 0;     height: 0;     overflow: hidden;     -webkit-transition: all 2s ease-in-out;     -moz-transition: all 2s ease-in-out;     -o-transition: all 2s ease-in-out;     transition: all 2s ease-in-out; } .accordionMenu .content .inner{     font-size: 1.2rem;     color: #2c97de;     line-height: 1.5;     background: white;     padding: 20px 10px; } 
Enter fullscreen mode Exit fullscreen mode

Step 4: Add some animations to the accordion menu

In general, the content associated with menus is hidden. When you click on that menu, the contents will appear. To do this, some special programming code has been used which I have given below.

.accordionMenu input[type=radio]:checked + label:after{     -webkit-transform: rotate(90deg);     -moz-transform: rotate(90deg);     -ms-transform: rotate(90deg);     -o-transform: rotate(90deg);     transform: rotate(90deg); }  .accordionMenu input[type=radio]:checked + label + .content{     max-height: 2000px;     height: auto; } 
Enter fullscreen mode Exit fullscreen mode

I have created this accordion menu using these few methods. If you want to know the complete information, you can watch the video above. Hopefully from this tutorial, you have learned how to create an accordion menu bar. If you have any problem, you can ask me by commenting. Special thanks to you for reading this article to the end.

accordioncsshtmlwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.