Simple Accordion Menu Using HTML and CSS

Simple Accordion Menu Using HTML and CSS

You will learn how to create accordion menus using simple HTML and CSS programming code. In the meantime, I have shown how to make one more accordion design. But in that case, I have shown how to hide the text arbitrarily using CSS code. In this article, I have shown you how to hide and show menus.

What is Accordion Menu? 

Accordion is a web element that you can use to organize many things on one website. HTML, CSS, and in many cases JavaScript programming code is used. In this case, the link or menu is added as needed by using the li tags in ul. You can hide and show them as you wish with the help of CSS code. In many cases, JavaScript programming code is used to hide and show this process.

 In most cases, this method is implemented using CSS code. The accordion menu designs enhance the quality and beauty of the website many times over. This is why the demand for this type of design has increased a lot.

Watch the video tutorial to know step by step

You can follow the video tutorial below to know the complete process of creating an accordion menu. In this case, I have used only HTML and CSS code to make it. If you want to know how to build it in full step by step and learn which programming code is used to create an element. But of course, you can follow the tutorial below. 

The accordion menu is designed in a completely modern way and is well suited to enhance the beauty. Here I have basically taken four menus and used about 6 submenus under them. You can increase the number of menus and submenus as needed. Here I have used icons next to each menu and made the sub-menus beautiful by the How Ever effect. When you move or click the mouse on each of the submenus, the submenus will have amazing beauty. In this case, I did not use any JavaScript programming code. I used CSS code to hide and show HTML menus.

Related posts

 Other posts related to this post will help you increase your knowledge of HTML and CSS. You can follow the link below.

1. Create An FAQ Accordion Menu

2. Personal Portfolio Website Tutorial

3. Sidebar Menu Using Only HTML and CSS

4. Glass Morphism Profile Card UI Design

5. Beautiful Transparent Login Form


How to create accordion menu using HTML & CSS 

 Below I have given the necessary HTML and CSS code to make it. If you want to make it yourself or use this menu elsewhere, you can do so very easily. For this, you will basically add the HTML code in the HTML file and add the CSS code in the CSS file. I used the CDN icon library (<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">).You must use the CDN Icon Library on your webpage.

HTML Code:

<div class="wrapper">
        <ui class="mainMenu">
            <li class="item" id="account">
                <a href="#account" class="btn"><i class="fa fa-user-circle"></i>My Account</a>
                <div class="subMenu">
                    <a href="">Item-1</a>
                    <a href="">Item-2</a>
                    <a href="">Item-3</a>
                </div>
            </li>
            <li class="item" id="about">
                <a href="#about" class="btn"><i class="fa fa-address-card"></i>About</a>
                <div class="subMenu">
                    <a href="">Item-1</a>
                    <a href="">Item-2</a>
                </div>
            </li>
            <li class="item" id="support">
                <a href="#support" class="btn"><i class="fa fa-info"></i>Support</a>
                <div class="subMenu">
                    <a href="">Item-1</a>
                </div>
            </li>
            <li class="item">
                <a href="#" class="btn"><i class="fa fa-sign-out"></i>Log Out</a>
            </li>
        </ui>
    </div>

CSS Code:

*{
    margin: 0;
    padding: 0;
    font-family: 'lato';
    list-style: none;
    text-decoration: none;
}
body{
    background-color: rgb(255, 255, 255);
}

.wrapper{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.mainMenu{
    width: 250px;
    display: block;
    border-radius: 10px;
    overflow: hidden;
}
.item{
    border-top: 1px solid #21a9e9;
    overflow: hidden;
}
.btn{
    display: block;
    padding: 15px 20px;
    background-color: #21a9e9;
    color: #fff;
    position: relative;

}
.btn:before{
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right:8px solid transparent;
    border-top:10px solid #21a9e9;
    right: 15px;
    bottom: -10px;
    z-index: 9;
    
}
.btn i {
    margin-right: 7px;
    margin-left: -5px;
    font-size: 13px;
}
.subMenu{
    background: #232b50;
    overflow: hidden;
    transition: max-height 0.7s;
    max-height: 0;
}
.subMenu a{
    display: block;
    padding: 15px 20px;
    color: #fff;
    font-size: 14px;
    border-bottom: 1px solid #394c7f;
    position: relative;
    
}
.subMenu a:before{
    content: '';
    opacity: 0;
    transition: opacity 0.3s;

}
.subMenu a:hover:before{
    content: '';
    position: absolute;
    height: 0;
    width: 6px;
    left: 0;
    top:0;
    opacity: 1;
    /* background-color: #d8d824; */
    border-top: 24px solid transparent;
    border-left: 11px solid #ffffff;
    border-bottom: 24px solid transparent;
}
.subMenu a:after{
    content: '';
    opacity: 0;
    transition: opacity 0.3s;

}
.subMenu a:hover:after{
    content: '';
    position: absolute;
    height: 0;
    width: 6px;
    right: 0px;
    top:0;
    opacity: 1;
    /* background-color: #d8d824; */
    border-top: 24px solid transparent;
    border-right: 11px solid #ffffff;
    border-bottom: 24px solid transparent;
}
.subMenu a:hover{
    background: #273057;
    background: -moz-linear-gradient(top, #273057 0%, #273057 50%, #394c7f 51%, #394c7f 100%);
    background: -webkit-linear-gradient(top, #273057 0%,#273057 50%,#394c7f 51%,#394c7f 100%);
    background: linear-gradient(to bottom, #273057 0%,#273057 50%,#394c7f 51%,#394c7f 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#273057', endColorstr='#394c7f',GradientType=0 );
    transition: all 0.3s;
    border-bottom: 2px solid #394c7f;
}
.subMenu a:last-child{
    border:none;
}
.item:target .subMenu{
    max-height: 10em;
}



Hopefully, this tutorial has completely helped you to design the accordion menu and you have learned completely. You can also download the source code completely free using the download button above. If you want to know how to make it in full step by step, you can follow the video tutorial above. 

If you like this design, please let me know in the comments. This will encourage me to create new designs. If you like the video, be sure to like the video, and don't forget to subscribe to the channel. Special thanks to you for reading to the end of the article



Thank you, Please Visit again


Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.