<div class="grid">
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">1</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">2</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">3</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">4</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">5</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">6</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">7</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">8</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">9</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">10</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">11</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">12</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">13</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">14</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">15</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">16</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">17</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">18</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">19</div>
  </a>
  <a class="item" href="https://haltu.github.io/muuri/" target="_blank">
    <div class="item-content">20</div>
  </a>
</div>
.grid {
  position: relative;
}
.item {
  position: absolute;
  width: 200px;
  height: 200px;
  line-height: 200px;
  margin: 5px;
  z-index: 1;
  text-decoration: none;
}
.item:hover {
  text-decoration: none;
}
.item.muuri-item-hidden {
  z-index: 0;
}
.item.muuri-item-releasing {
  z-index: 2;
}
.item.muuri-item-dragging {
  z-index: 3;
}
.item-content {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  background: red;
  font-size: 50px;
  color: white;
  cursor: pointer;
}
.item.muuri-item-dragging .item-content {
  background: blue;
}
.item.muuri-item-releasing .item-content {
  background: blueViolet;
}
var grid = new Muuri('.grid', {
  dragEnabled: true
});

// If a grid item is an anchor element Muuri
// applies a simple algorithm to detect whether
// user is trying to click the item or drag the
// item. However, Muuri needs a little help.
// You need to manually prevent the click event's
// default action.
[].slice.call(document.querySelectorAll('.item'))
  .forEach(function (elem) {
    elem.addEventListener('click', function (e) {
      e.preventDefault();
    });
  });

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/web-animations/2.3.2/web-animations.min.js
  2. https://cdn.jsdelivr.net/gh/haltu/[email protected]/dist/muuri.min.js