Coder Wrap provides free to use snippets Coder Wrap provides free to use snippets

Back to Accordions
Preview Source Code
Download
HTML
CSS
/**Typeo CSS Start (Note if is not need so remove)**/
@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");

* {
 box-sizing: border-box;
}

body {
 font-family: "Poppins", sans-serif;
 color: #000;
 box-sizing: border-box;
 background-color: #f6f4fe;
}

.cw-fix {
 max-width: 800px !important;
 margin: auto;
 width: 100%;
 padding: 40px 0px;
}

/**Typeo CSS End (Note if is not need so remove)**/
.cw-section {
 display: flex;
 flex-direction: column;
 row-gap: 2rem;
}

.faq-top {
 text-align: center;
}

.faq-top p {
 margin: 0px;
}

.cw-section__title {
 font-size: 2rem;
 text-align: center;
 margin-bottom: 0px;
 color: #332470;
}

.cw-section__title span {
 color: #6A49F2;
}

.cw-accordion {
 width: 100%;
 display: flex;
 flex-direction: column;
 align-items: center;
 row-gap: 1rem;
}

.cw-accordion__item {
 padding: 0.8rem 1rem;
 background: #fff;
 position: relative;
 width: 100%;
 cursor: pointer;
 box-shadow: 0 4px 10px #ede9fe;
 border: #cdcdcd 1px solid;
}

.cw-accordion__item .cw-label {
 padding-left: 26px;
 font-size: 20px;
 position: relative;
 width: 100%;
 display: inline-block;
 font-size: 15px;
 font-weight: 500;
}

.cw-accordion__item .cw-label:after {
 position: absolute;
 left: 0;
 content: "+";
 font-size: 16px;
 top: 3px;
 border: #000 1px solid;
 width: 16px;
 height: 16px;
 border-radius: 100%;
 line-height: 1.1;
 text-align: center;
}

.cw-accordion__item .cw-label.cw-open:after {
 transform: rotate(45deg);
}

.cw-accordion__item .cw-acordion-cont {
 height: 0px;
 overflow: hidden;
 transition: 0.4s;
 -webkit-transition: 0.4s;
 font-size: 15px;
 padding-left: 25px;
 padding-right: 25px;
}

.cw-accordion__item .cw-acordion-cont ul {
 padding-left: 20px;
}

.cw-accordion__item .cw-acordion-cont ul li {
 margin: 7px 0px;
}

.cw-accordion__item .cw-open + .cw-acordion-cont {
 height: auto;
 padding-top: 15px;
 padding-bottom: 15px;
}

.faq-contact {
 text-align: center;
 padding: 10px 0;
}

.faq-contact h3 {
 margin: 0px 0px 15px 0px;
}

.faq-contact .contact-btn {
 padding: 8px 20px;
 background-color: #000;
 color: #fff;
 text-decoration: none;
 display: inline-block;
 border: #000 1px solid;
 transition: 0.5s all;
 font-weight: 700;
}

.faq-contact .contact-btn:hover {
 background-color: transparent;
 color: #000;
}
@media(max-width:992px) {
.cw-section__title {
     font-size: 1.5rem;
}
}
JS
let items = document.querySelectorAll(".cw-accordion .cw-accordion__item .cw-label");
items.forEach(function (t) {
t.addEventListener("click", function (e) {
 items.forEach(function (e) {
 e !== t || e.classList.contains("cw-open")
 	? e.classList.remove("cw-open")
 	: e.classList.add("cw-open");
 });
});
});

Related Snippets

Leave a comment

Your email address will not be published. Required fields are marked *