<div class="content">
  <p class="collapsible">
This is a block of text that is collapsed by scale. It is performant, but unfortunately, it warps the contents when it opens and closes, and leaves a gap in its place.
Praesent nec feugiat enim. In vitae elementum erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque vitae lectus varius ipsum tempor maximus in ac eros. Mauris lacus lorem, elementum non lacus vitae, interdum commodo odio.
.collapsible {
  transition: transform 0.5s ease-out;
  transform-origin: top left;
.collapsed {
  transform: scaleY(0);
document.querySelector('button').addEventListener('click', () => { document.querySelector('.collapsible').classList.toggle('collapsed');});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.