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: #444;
  box-sizing: border-box;
  background-color: #f5f5f5;
}
/**Typeo CSS End (Note if is not need so remove)**/

.cw-content {
  max-width: calc(100vw - 20px);
  margin: 0 auto 150px;
}

.cw-accordion {
  max-width: 600px;
  margin: 50px auto;
  display: grid;
  grid-gap: 15px;
}

.cw-accordion__block-title {
  font-weight: bold;
  font-size: 14px;
  color: #424242;
  text-transform: uppercase;
}

.cw-accordion__item {
  display: block;
  padding: 20px;
  cursor: pointer;
  box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  overflow: hidden;
  transition: all 150ms ease;
}
.cw-accordion__item:not(:last-child) {
  border-bottom: 1px solid #fafafa;
}

.cw-accordion__title {
  font-size: 16px;
  line-height: 1.5;
  transition: all 150ms ease;
  position: relative;
  padding-right: 30px;
}
.cw-accordion__title::after,
.cw-accordion__title::before {
  content: "";
  width: 16px;
  height: 2px;
  background-color: #666;
  position: absolute;
  right: 0;
  top: 8px;
  transition: all 150ms ease;
}
.cw-accordion__title::after {
  transform: rotate(90deg);
}

.cw-accordion__content {
  transform: translateY(50%);
  color: #999;
  font-size: 16px;
  line-height: 1.5;
  max-height: 0;
  opacity: 0;
  transition: all 150ms ease;
}

.cw-accordion__item [type="checkbox"],
.cw-accordion__item [type="radio"] {
  display: none;
}
.cw-accordion__item [type="radio"]:checked + .cw-accordion__title,
.cw-accordion__item [type="checkbox"]:checked + .cw-accordion__title {
  margin-bottom: 10px;
  font-size: 20px;
}
.cw-accordion__item [type="radio"]:checked + .cw-accordion__title::after,
.cw-accordion__item [type="checkbox"]:checked + .cw-accordion__title::after {
  transform: rotate(45deg);
}
.cw-accordion__item [type="radio"]:checked + .cw-accordion__title::before,
.cw-accordion__item [type="checkbox"]:checked + .cw-accordion__title::before {
  transform: rotate(-45deg);
}
.cw-accordion__item
  [type="radio"]:checked
  + .cw-accordion__title
  + .cw-accordion__content,
.cw-accordion__item
  [type="checkbox"]:checked
  + .cw-accordion__title
  + .cw-accordion__content {
  transform: translateY(0);
  max-height: none;
  opacity: 1;
}

Related Snippets

Leave a comment

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