<h1>Slide down scaleY transition</h1>

<table>
  <thead>
    <tr>
      <th><label for="toggle-margin"><input id="toggle-margin" type="checkbox" /> Slide down (scaleY)</label></th>
    
      <th><label for="toggle-jquery"><input id="toggle-jquery" type="checkbox" /> Slide down (jquery)</label></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>
<ul id="menu-margin">
  <li>Lorem ipsum dolor</li>
  <li>Recusandae vitae</li>
  <li>Commodi sint molestias</li>
  <li>Distinctio consequatur</li>
  <li>Pariatur nisi possimus</li>
  <li>Autem quod vitae</li>
  <li>Ut vero veniam</li>
</ul>
      </td>
      <td>
<ul id="menu-jquery">
  <li>Lorem ipsum dolor</li>
  <li>Recusandae vitae</li>
  <li>Commodi sint molestias</li>
  <li>Distinctio consequatur</li>
  <li>Pariatur nisi possimus</li>
  <li>Autem quod vitae</li>
  <li>Ut vero veniam</li>
</ul>        
      </td>
    </tr>
  </tbody>
</table>

<p>Mollitia maiores dicta ipsum autem. Soluta excepturi, perferendis aspernatur voluptatum consequatur. Odio, architecto, tempora! Iure earum, at quasi incidunt ipsum libero dicta aliquid. Magni in aspernatur incidunt, fugit odit! Maiores.</p>
<p>Voluptatum sit explicabo sapiente unde laboriosam error porro, iste non, corporis libero tenetur enim velit. Minus neque sint ab non, at accusamus. Officiis iste quae, nihil, ratione sed possimus accusantium.</p>
body {
  font: normal 14px/1.3 "Trebuchet MS", sans-serif;
  
  max-width: 30em;
  margin: 1em auto;
}

table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
}
caption, th, td {
  text-align: left;
  vertical-align: top;
}
caption {
  margin: .5em 0;
}
th, td {
  padding: 0 1em;
  font-weight: normal;
}
td {
  height: 20em;
}

ul {
  vertical-align: top;
  margin: 1em 0;
  list-style: none;
  padding: 0;
  background: #370;
  color: #fee;
  opacity: 1;
  transform-origin: 0 0;
  transition:
    opacity 0.3s ease,
    transform 0.3s cubic-bezier(.2,.38,.72,1.3);
}
ul[hidden] {
  display: block;
  margin: 0;
  height: 0;
  transform: scaleY(0);
  transition:
    opacity 0.1s ease,
    transform 0.12s ease-out;
}
li {
  padding: .5em .7em;
}
(function() {
  'use strict';

	var checkboxMargin = document.getElementById( 'toggle-margin' );
  var boxMargin = document.getElementById( 'menu-margin' );

  // show/hide?
  function toggleMargin() {
    boxMargin.hidden = ! checkboxMargin.checked;
  }

  // toggle on click
  checkboxMargin.addEventListener( 'click', toggleMargin );
  
  // initial state
  toggleMargin();
}());

// jquery version
(function() {
  'use strict';
  
  var checkboxJquery = $( '#toggle-jquery' );
  var boxJquery = $( '#menu-jquery' );
  
  function toggleJquery() {
    if ( checkboxJquery.is( ':checked' )) {
      boxJquery.stop( true, true ).slideDown( 300 );
    } else {
      boxJquery.stop( true, true ).hide();
    }
  }
  
  // toggle on click
  checkboxJquery.on( 'click', toggleJquery );
  
  // initial state
  toggleJquery();

}());

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js