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

🗙
Login
Register

Create Account

Cancel
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;
}

.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: 1rem;
 background: #fff;
 position: relative;
 border-radius: 8px;
 width: 100%;
 cursor: pointer;
 box-shadow: 0 4px 10px #ede9fe;
}

.cw-accordion__item .cw-label {
 padding-right: 20px;
 font-size: 20px;
 position: relative;
 width: 100%;
 display: inline-block;
}

.cw-accordion__item .cw-label:after {
 position: absolute;
 right: 0;
 content: "+";
 font-size: 30px;
 top: -6px;
}

.cw-accordion__item .cw-label.cw-open:after {
 content: "−";
}

.cw-accordion__item .cw-acordion-cont {
 height: 0px;
 overflow: hidden;
 transition: 0.4s;
 -webkit-transition: 0.4s;
}

.cw-accordion__item .cw-open + .cw-acordion-cont {
 height: auto;
 padding-top: 25px;
 padding-bottom: 15px;
}
@media(max-width: 992px) {
  .cw-fix {
    padding: 0px 15px;
  }
  .cw-section {
    row-gap: 0rem;
}
.cw-section__title {
  font-size: 1.5rem;
}
.cw-accordion__item .cw-label {
      font-size: 16px;
}
.cw-accordion__item .cw-label:after {
      top: -9px;
}
.cw-accordion__item {
      padding: 0.8rem;
}
.cw-accordion__item .cw-open + .cw-acordion-cont {
    padding-top: 5px;
    padding-bottom: 5px;
    font-size: 14px;
}
}
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 *