Basic JS Collapsible

Live Demo
Responsive basic CSS Cards

Collapsible Example

Collapsible content goes here!

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.


<!--Basic JS Collapsible start-->
<h2>Collapsible Example</h2>
  
  <button class="collapsible">Click to toggle</button>
  <div class="content">
         <h5>Collapsible content goes here!</h5>
         <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
  </div>
<!--Basic JS Collapsible end-->


.collapsible {
      background-color: #3c76fe;
      color: white;
      cursor: pointer;
      padding: 18px;
      width: fit-content;
      border: none;
      text-align: left;
      outline: none;
      font-size: 15px;
      transition: background-color 0.3s;
      border-radius: 10px;
    }
    
    .collapsible:hover {
    background-color: #1752da;
    }
    
    .collapsible.active {
      background-color: #1953db;
    }

    .content {
      padding: 0 18px;
      overflow: hidden;
      max-height: 0;
      transition: max-height 0.3s ease-out;
      background-color: #f1f1f1;
      width: 79%;
      margin-top: 10px;
    }


<script>
var coll = document.getElementsByClassName("collapsible");
    var i;

    for (i = 0; i < coll.length; i++) {
      coll[i].addEventListener("click", function() {
        this.classList.toggle("active");
        var content = this.nextElementSibling;
        if (content.style.maxHeight){
          content.style.maxHeight = null;
        } else {
          content.style.maxHeight = content.scrollHeight + "px";
        } 
      });
    }
</script>


<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>




Basic JS Collapsible
Basic JS Collapsible

Privacy Policy | Cookies Policy | Contact Us

We use cookies to improve your experience. By using our site, you agree to our cookie policy.