<html>
  <body>
    <button onClick="toggle()">Click to Flip</button>
    <div class="item-container">
      <div class='item'>Item 1</div>
      <div class='item'>Item 2</div>
      <div class='item'>Item 3</div>
      <div class='item'>Item 4</div>
    </div>
  </body>
</html>

.item-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
}

div.item {
  background: #283747;
  color: white;
  margin: 1rem;
}

.flip {
  grid-template-columns: 1fr; 
}
function toggle() {
  const itemContainer = document.querySelector('.item-container');
  itemContainer.classList.toggle('flip');
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/redux/4.0.1/redux.min.js