<a class="toggle" href="#node" data-toggle>Toggle</a>
<div class="node" id="node" data-node></div>
*, *:before, *:after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, 
body {
  width: 100%;
  height: 100%;
}

body {
  display: flex;
  font-family: sans-serif;
  background-color: #fffeca;
}

.node {
  width: 100px;
  height: 100px;
  margin: auto;
  background-color: #00f;
  
  // initial state
  opacity: 0;
  transform: translateY(100%) rotate(360deg);
}

.toggle {
  position: absolute;
  top: 20px;
  left: 50%;
  padding: 6px 10px 5px 10px;
  
  text-align: center;
  text-decoration: none;
  border: 1px solid #00f;
  border-radius: 3px;

  transform: translateX(-50%);
}
View Compiled
const node = document.querySelector('[data-node]')
const toggle = document.querySelector('[data-toggle]')
let initial = true

const keyframes = {
  transform: [ 
    'translateY(100%) rotate(360deg)', 
    'translateY(0%) rotate(0deg)' 
  ], 
  opacity: [ 0, 1 ],
  easing: 'ease-out',
}

const options = {
  duration: 500,
}

function animateTo(element, keyframes, options) {
  const animation = element.animate(
    keyframes, 
    {...options, fill: 'both'}
  )
  
  animation.addEventListener('finish', () => {
    animation.commitStyles()
    animation.cancel()
  })
  
  return animation
}

function handleToggle(event) {
  event.preventDefault()
  animateTo(node, keyframes, options)
}

toggle.addEventListener('click', handleToggle)
View Compiled
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.