Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!doctype html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" href="https://use.typekit.net/bjb6aay.css">
  <link rel="stylesheet" href="style.css">
  <title>Document</title>
</head>

<body>
  <nav class="menu">
    <a class="menu__item" data-img="https://images.unsplash.com/photo-1611374055384-781ee99d62d3?ixid=MXwxMjA3fDB8MHx0b3BpYy1mZWVkfDJ8cm5TS0RId3dZVWt8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop">
      <span class="menu__item-text"><span class="menu__item-textinner">Maria Costa</span></span>
    </a>
    <a class="menu__item" data-img="https://images.unsplash.com/photo-1611398100352-8c50d2c30f2c?ixid=MXwxMjA3fDB8MHx0b3BpYy1mZWVkfDF8cm5TS0RId3dZVWt8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop">
      <span class="menu__item-text"><span class="menu__item-textinner">Lana Ferrari</span></span>
    </a>
    <a class="menu__item" data-img="https://images.unsplash.com/photo-1559782035-2646076bc1f8?ixid=MXwxMjA3fDB8MHx0b3BpYy1mZWVkfDV8cm5TS0RId3dZVWt8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60">
      <span class="menu__item-text"><span class="menu__item-textinner">Franklin Roth</span></span>
    </a>
    <a class="menu__item" data-img="img/4.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Cristie Noe</span></span>
    </a>
    <a class="menu__item" data-img="img/5.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Wilma Quest</span></span>
    </a>
    <a class="menu__item" data-img="img/6.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Gary Winston</span></span>
    </a>
    <a class="menu__item" data-img="img/7.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Nesta Freeman</span></span>
    </a>
    <a class="menu__item" data-img="img/8.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Jolanda French</span></span>
    </a>
    <a class="menu__item" data-img="img/9.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Samantha Dunne</span></span>
    </a>
    <a class="menu__item" data-img="img/10.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Tony Albert</span></span>
    </a>
    <a class="menu__item" data-img="img/11.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Jacky Speed</span></span>
    </a>
    <a class="menu__item" data-img="img/12.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Carlton Holle</span></span>
    </a>
    <a class="menu__item" data-img="img/13.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Kylla Maushet</span></span>
    </a>
    <a class="menu__item" data-img="img/14.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Fernando Castello</span></span>
    </a>
    <a class="menu__item" data-img="img/15.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Sofie Henriette</span></span>
    </a>
    <a class="menu__item" data-img="img/16.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Adelie Bisset</span></span>
    </a>
    <a class="menu__item" data-img="img/17.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Takato Yang</span></span>
    </a>
    <a class="menu__item" data-img="img/18.jpg">
      <span class="menu__item-text"><span class="menu__item-textinner">Hadrian Kaiser</span></span>
    </a>
    <p class="credits">Images by <a href="https://www.behance.net/AndrewLili">Andrey Yakovlev and Lili Aleeva</a>,
      licensed under <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/deed.en_US">CC BY-NC-ND 4.0</a></p>
  </nav>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.6.0/gsap.min.js"></script>
  <script src="script.js"></script>
</body>

</html>
              
            
!

CSS

              
                :root {
  margin: 0;
  --color-text: #111;
  --color-bg: #edeee9;
  --color-link: #000;
  --color-link-hover: #000;
  --color-menu: #000;
  --color-menu-hover: #f32015;
  color: var(--color-text);
  background-color: var(--color-bg);
  --cursor-stroke: #000;
  --cursor-fill: #000;
  --cursor-stroke-width: 1px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: degular, sans-serif;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--color-bg);
}

.menu {
  padding: 5rem 0;
}

.menu__item {
  position: relative;
  display: flex;
  flex: none;
  padding-left: 25vw;
  cursor: pointer;
}

.menu__item-textinner {
  display: block;
  font-family: goldenbook, serif;
  font-weight: 300;
  text-transform: uppercase;
  white-space: nowrap;
  font-size: 4vw;
  color: var(--color-menu);
  padding: 1vh 0;
}

.hover-reveal {
  position: absolute;
  left: 0;
  top: 0;
  z-index: -1;
  width: 220px;
  height: 320px;
  opacity: 0;
}

.hover-reveal__inner {
  position: relative;
  width: 100%;
  height: 100%;
}

.hover-reveal img {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: 50% 50%;
}

              
            
!

JS

              
                const layout = () => {
  let links = gsap.utils.toArray(".menu__item");
  links.forEach((link) => {
    const { img } = link.dataset;
    const reveal = document.createElement("div");
    reveal.setAttribute("class", "hover-reveal");
    const revealInner = document.createElement("div");
    revealInner.setAttribute("class", "hover-reveal__inner");
    const revealImage = document.createElement("img");
    revealImage.setAttribute("class", "hover-reveal__image");
    revealImage.setAttribute("src", img);
    revealInner.appendChild(revealImage);
    reveal.appendChild(revealInner);
    link.appendChild(reveal);
  });
};

const hoverRevealInit = () => {
  let links = gsap.utils.toArray(".menu__item");
  links.forEach((link) => {
    link.addEventListener("mouseenter", hoverReveal);
    link.addEventListener("mouseleave", hoverReveal);
  });
};

const hoverReveal = (e) => {
  const revealImage = e.target.querySelector(".hover-reveal");
  if (e.type === "mouseenter") {
    let xPos = e.clientX - e.target.offsetLeft;
    let yPos = e.clientY - e.target.offsetTop;
    console.log(xPos, yPos);
    let tl = gsap.timeline();
    tl.to(
      revealImage,
      0.8,
      { autoAlpha: 1, zIndex: 5, ease: "Power2.InOut" },
      0
    ).to(revealImage, 0.4, { y: yPos, x: xPos }, 0);
  } else {
    let tl = gsap.timeline();
    tl.to(revealImage, 0.8, { autoAlpha: 0, zIndex: -1, ease: "Power2.InOut" });
  }
};
const init = () => {
  layout();
  hoverRevealInit();
};

window.addEventListener("load", function () {
  init();
});

              
            
!
999px

Console