css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              
<h1>The spinning hexagonal click-spot show</h1>

<p>A furtherance to a click animation I saw a while back over on codrops.<br>Rewritten to remove library dependencies, added spin, et voila&hellip;</p>


<div class=grd_parent>
  <div class=grd-2>

    <article class=grd_itm>
      <a class=grd_lnk-small data-spot href="#">
        <div class=grd_copy>Click me (link)</div>
      </a>
    </article>

    <article class=grd_itm>
      <button class=grd_btn-small data-spot>
        <div class=grd_copy>Click me (button)</div>
      </button>
    </article>

    <article class=grd_itm>
      <a class=grd_lnk data-spot href="#">
        <div class=grd_copy>Click me (link)</div>
      </a>
    </article>

    <article class=grd_itm>
      <button class=grd_btn data-spot>
        <div class=grd_copy>Click me (button)</div>
      </button>
    </article>

  </div>
</div>

<p>As used on on my latest <a class=lnk title="[new window]" target=_blank href="https://websemantics.uk/">homepage</a> update.</p>



<svg class=visually-hidden>
  <defs>
    <!-- method and matrix stolen from codrops (lost reference to original) -->
    <symbol id="spot-hexagon">
      <path d="M9.6 76.5L4 29 42.6.5l44 19L91.8 67 53.4 95.5l-44-19z"/>
    </symbol>
    <symbol id="spot-hexagons" viewbox="0 0 96 96">
      <use xlink:href="#spot-hexagon" opacity=".3"/>
      <use xlink:href="#spot-hexagon" opacity=".4" transform="matrix(.5 0 0 .5 25 25)"/>
      <use xlink:href="#spot-hexagon" opacity=".5" transform="matrix(.3 0 0 .3 36.3 36.3)"/>
    </symbol>
  </defs>
</svg>


<p>Not finding the original reference is bugging me. I'm pretty certain it was on <a href="https://tympanus.net/codrops/">codrops</a>. Apologies to the originator. If you know where it came from please add a comment.</p>




[[[https://codepen.io/2kool2/pen/mKeeGM]]]
            
          
!
            
              * {box-sizing: border-box;}
html {

  --textColor: hsl(269, 25%, 23%);
  --titleColor: hsl(269, 19%, 30%);

  --spacing-xlarge:   2.618rem;
  --spacing-large:    1.618rem;
  --spacing-medium:   1rem;
  --spacing-small:    0.618rem;
  --spacing-xsmall:   0.382rem;

  --fs1: 1.618rem; /* h1 */
  --fs2: 1.382rem; /* h2 */
  --fs3: 1.115rem; /* h3 */
  --fs4: 1rem; /* p */
  --fs5: .854rem; /* smaller */

  --lh1: 1.236; /* h1 */
  --lh2: 1.3; /* h2 */
  --lh3: 1.3; /* h3 */
  --lh4: 1.45; /* p */
  --lh5: 1.5; /* smaller */

  font-family: sans-serif;
  line-height: var(--lh4);
  color: #5a5a5a;
  background-color: #E9F0FB;
}
body {
  margin: 0;
  text-align: center;
}
h1 {
  font-size: var(--fs1);
  line-height: var(--lh1);
  font-weight: 100;
}
p {
  padding: var(--spacing-medium);
}
.lnk {text-decoration: none; border-bottom: 1px solid currentColor;}

/* The layout grid */

.grd_parent {
  --spacing: var(--spacing-medium);
  padding: var(--spacing);
}
[class^="grd-"] {
  --columns: 1fr;
  display: grid;
  grid-gap: var(--spacing);
  grid-template-columns: var(--columns);
}
@media (min-width: 40em) { /* 640px */
  [class^="grd-2"] {
    --columns: 1fr 1fr;
  }
}
[class^="grd_itm"] {
  border: 1px solid hsla(214, 71%, 47%, .15);
  padding: 0;
  min-width: 300px;
}

/* The link and button */
[class^="grd_btn"] {
  cursor: pointer;
  width: 100%;
  font-size: inherit;
}
[class^="grd_lnk"],
[class^="grd_btn"] {
  display: block;
  min-height: 15rem;
  position: relative;
  text-decoration: none;
  padding: 0.5rem;
  color: var(--textColor);
  border: 1px solid rgba(255,255,255,.7);
  background-color: rgba(225,255,235,.3);
  transition:
    box-shadow .3s ease,
    background-color .3s ease,
    transform .7s ease-in;
}
[class^="grd_lnk"]:hover,
[class^="grd_lnk"]:focus,
[class^="grd_btn"]:hover,
[class^="grd_btn"]:focus {
  color: inherit;
  outline: 0 solid;
  will-change: background-color, box-shadow, border-color;
  background-color: rgba(225,255,235,.6);
  box-shadow: 0 4px 4px hsla(269, 19%, 30%, .5);
  border-color: hsl(0, 0%, 99.8%);
}
[class^="grd_"][class*="-small"] {
  background-color: rgba(255,255,235,.4);
  min-height: 4rem;
}
[class^="grd_"][class*="-small"]:hover,
[class^="grd_"][class*="-small"]:focus {
  background-color: rgba(255,255,235,.6);
}



.grd_copy {
  text-transform: uppercase;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate3d(-50%, -50%, 0);
  color: hsl(214, 71%, 45%);
}



/* Hexagonal activation spot */

[data-spot] {
  position: relative;
  overflow: hidden;
}
[data-spot] * {
  pointer-events: none;
}
.spot-hex {
  display: block;
  position: absolute;
  overflow: hidden;
  transform: rotatez(0deg) scale(0);
  opacity: 1;
}
.spot-hex use {
  fill: hsl(214, 100%, 70%);
}
.spot_parent-clicked {
  box-shadow: 0 0 0 rgba(0,0,0,0) !important;
}
.spot-hex-on {
  will-change: opacity, transform;
  animation: spot-hex-open 1s linear;
}

@keyframes spot-hex-open {
  0% {
    opacity: 1;
    transform: rotatez(0deg) scale(.1);
  }
  100% {
    opacity: 0;
    transform: rotatez(60deg) scale(3);
  }
}
            
          
!
            
              var supportsES6=function(){try{return new Function("(a = 0) => a"),!0}catch(n){return!1}}();


// Hexagonal spot click animation applied to objects with the attribute data-spot
// SVG hexagonal symbol (#spot-polygones) needs to be in the HTML
(function () {

  "use strict";

  if (!supportsES6) {return false;}

  const dataAttr = "[data-spot]";
  const spotClass = "spot-hex";
  const spotOnClass = "spot-hex-on";
  const parentClickedClass = "spot_parent-clicked";
  const symbolId = "#spot-hexagons";

  const _addSpot = (box) => {
    const NS = "http://www.w3.org/2000/svg";
    const svg = document.createElementNS(NS, "svg");
    const use = document.createElementNS(NS, "use");
    use.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", symbolId);
    svg.appendChild(use);
    svg.classList.add(spotClass);
    box.insertBefore(svg, box.firstChild);
  };

  const _activateSpot = (e, box) => {
    const spot = e.target.querySelector("." + spotClass);

    if (spot) {
      // Handle multiple activations
      spot.classList.remove(spotOnClass);

      // Requires all children to have pointer-events:none
      const dia = Math.max(box.clientWidth, box.clientHeight);
      const x = e.offsetX - (dia / 2);
      const y = e.offsetY - (dia / 2);
      spot.setAttribute("style", "top: " + y + "px; left: " + x + "px; " + "height: " + dia + "px; width: " + dia + "px");
      requestAnimationFrame(() => {
        spot.classList.add(spotOnClass);
        spot.parentElement.classList.add(parentClickedClass);
        spot.addEventListener("animationend", function(e){
          spot.classList.remove(spotOnClass);
          spot.parentElement.classList.remove(parentClickedClass);
        }, {once: true});

      });
    }
  };

  const _boxClicked = (e) => {
    const activationObj = e.target.querySelector("a") ||  e.target.querySelector("button");
    _activateSpot(e, e.target);

    if (activationObj) {
     activationObj.click();
    }
  };

  (() => {
    const boxes = document.querySelectorAll(dataAttr);
    for (const box of boxes) {
      _addSpot(box);
      box.addEventListener("click", _boxClicked, false);
    }
  })();

 }());

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console