Create an accordion element in HTML without JavaScript
<div class="accordion">
  <div class="title">
    <h1>Accordion</h1>
    <h2>Example using pure HTML</h2>
  </div>
  <details>
    <summary><i class="las la-apple-alt red"></i>Most Popular Fruits</summary>
    <ul>
      <li>Apple</li>
      <li>Bananas</li>
      <li>Strawberries</li>
      <li>Grapes</li>
      <li>Oranges</li>
      <li>Watermelon</li>
      <li>Lemons</li>
    </ul>
  </details>
  <details>
    <summary>
      <i class="las la-carrot green"></i>Most Popular Vegetables
    </summary>
    <ul>
      <li>Potatoes</li>
      <li>Onions</li>
      <li>Carrots</li>
      <li>Lettuce</li>
      <li>Bell Peppers</li>
      <li>Broccoli</li>
    </ul>
  </details>
</div>
/* Example style, not required */
html {
  height: 100%;
}
body {
  margin: 0;
  background: linear-gradient(231deg, #ffffff 0%, #f0f0f0 99%);
  padding-top: 100px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}
.accordion {
  margin: auto;
  width: 350px;
  background-color: #fff;
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1);
  opacity: 0.8;
  font-size: 14px;
}
.accordion .title {
  padding-left: 15px;
}
.accordion .title h1 {
  font-size: 24px;
  line-height: 30px;
  margin-bottom: 0;
}
.accordion .title h2 {
  font-size: 16px;
  line-height: 20px;
  margin-top: 0;
  padding: 0;
  font-weight: 500;
}
.accordion details summary {
  line-height: 50px;
  padding-left: 15px;
  padding-right: 15px;
  font-weight: 400;
  cursor: pointer;
  border-radius: 10px;
  position: relative;
  user-select: none;
}
.accordion details summary i {
  font-size: 32px;
  vertical-align: middle;
  margin-right: 15px;
}
.accordion details summary i.purple {
  color: rgb(103, 58, 183);
}
.accordion details summary i.orange {
  color: rgb(230, 74, 25);
}
.accordion details summary i.red {
  color: rgb(229, 57, 53);
}
.accordion details summary i.green {
  color: rgb(67, 160, 71);
}
.accordion details[open] summary,
.accordion details summary:hover {
  background-color: rgba(0, 0, 0, 0.05);
}
.accordion details[open] summary{
  font-weight: bold;
}
.accordion details summary:after {
  content: "+";
  position: absolute;
  display: block;
  line-height: 50px;
  top: 0px;
  right: 20px;
}
.accordion details[open] summary:after {
  content: "-";
}
.accordion details ::marker {
  font-size: 0;
}
.accordion details ul {
  margin: 0;
  margin-top: 10px;
  margin-bottom: 10px;
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
}
.accordion details ul li {
  cursor: pointer;
  padding: 10px;
  padding-left: 20px;
  border-radius: 5px;
  font-weight: bold;
}
.accordion details ul li:hover {
  background-color: rgba(0, 0, 0, 0.05);
}
// JS

Create an accordion element in HTML without JavaScript

  • Archivos
  • Index
  • Style
  • Script
  • README
  • CDN Agregar
  • line-awesome.min.css 1.3.0
HTML
PLEASE WAIT...