<div class="container">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer sed mauris bibendum, vehicula lacus eget, tempus sem. Morbi pretium metus eu accumsan tempor. Suspendisse potenti. Praesent id elit in magna posuere commodo. Duis id lectus a est sodales hendrerit. Sed auctor vehicula urna sit
    amet semper. Duis congue, enim ut condimentum volutpat, velit ex pulvinar lorem, sed luctus turpis nunc quis eros.</p>

  <button class="toggle-btn">
    <span class="more show">
      Show more info
      <svg width="24" height="24" viewBox="0 0 24 24">
        <path d="M0 7.33l2.829-2.83 9.175 9.339 9.167-9.339 2.829 2.83-11.996 12.17z"/>
      </svg>
    </span>
    <span class="less hide">
      Show less info
      <svg width="24" height="24" viewBox="0 0 24 24">
        <path d="M0 16.67l2.829 2.83 9.175-9.339 9.167 9.339 2.829-2.83-11.996-12.17z"/>
      </svg>
    </span>
  </button>

  <div class="info">
    <p>Mauris convallis, justo eget blandit rutrum, orci tortor vehicula massa, sit amet pulvinar augue urna sit amet velit. Cras tempus odio quis dui sollicitudin efficitur. Aliquam sollicitudin venenatis justo, at sollicitudin dui. Donec diam lorem, suscipit ut lobortis ut, semper aliquam metus. Nam sollicitudin, est id porta lobortis, justo ligula efficitur elit, ut tincidunt lectus nisl sed sapien. Proin ac volutpat lorem. Praesent sodales ultricies velit eget posuere.
      Vestibulum ornare tempor eleifend. Maecenas scelerisque lorem dui, eget commodo sapien lacinia a. Donec lorem erat, sagittis at nisl vel, ultricies tincidunt velit.</p>
  </div>

  <div>Mauris convallis, justo eget blandit rutrum, orci tortor vehicula massa, sit amet pulvinar augue urna sit amet velit. Cras tempus odio quis dui sollicitudin efficitur. Aliquam sollicitudin venenatis justo, at sollicitudin dui. Donec diam lorem, dictum volutpat lorem. Praesent sodales ultricies velit eget posuere.
    Vestibulum ornare tempor eleifend. Maecenas scelerisque lorem dui, eget commodo sapien lacinia a. Donec lorem erat, sagittis at nisl vel, ultricies tincidunt velit.</div>
</div>
* {
  padding: 0;
  margin: 0;
}

button {
  cursor: pointer;
  background: transparent;
  border: none;
  outline: none;
  color: #5a1bbe;
}

button:disabled {
  color: #5a1bbe;
}

svg {
  /*svg images by https://iconmonstr.com*/
  width: 16px;
  height: 16px;
}

.hide {
  display: none;
}

.show {
  display: flex;
}

body {
  font: normal 20px/1.5 Helvetica, sans-serif;
  margin-top: 25px;
  background: #f2f2f2;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 25px;
}

p, 
.toggle-btn {
  margin-bottom: 25px;
}

.toggle-btn {
  display: inline-block;
  font-weight: bold;
}

span {
  display: flex;
  align-items: center;
}

span svg {
  margin-left: 5px;
}

svg path {
  fill: #5a1bbe;
}

.info {
  overflow: hidden;
  transition: height .5s;
}
const toggleBtn = document.querySelector(".toggle-btn");
const info = document.querySelector(".info");
const less = document.querySelector(".less");
const more = document.querySelector(".more");

let infoHeight = info.offsetHeight;
info.style.height = 0;

toggleBtn.addEventListener("click", function() {
  this.disabled = true;

  more.classList.toggle("show");
  more.classList.toggle("hide");
  less.classList.toggle("show");
  less.classList.toggle("hide");

  const infoNewHeight = info.offsetHeight;

  if (infoNewHeight == 0) {
    info.style.height = `${infoHeight}px`;
  } else {
    info.style.height = 0;
  }

  setTimeout(() => {
    this.disabled = false;
  }, 500);
});

window.addEventListener("resize", () => {
  info.style.removeProperty("height");
  infoHeight = info.offsetHeight;

  if(more.classList.contains("hide")) {
    info.style.height = `${infoHeight}px`;
  } else {
    info.style.height = 0;
  }
});
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.