<div class="bg"></div>
<div class="container">
  <h1>Hover over the links</h1>
  But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will <a data-bg="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/freedom.jpg" href="https://elements.envato.com/playground-yard-superhero-freedom-child-boy-P6VKSJ4" target="_blank">freedom</a> you a account of the system, and expound the actual teachings of the great of the truth, <a data-bg="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/travel.jpg" href="https://elements.envato.com/traveler-with-headphones-R3EDGQ8" target='_blank'>travel</a> master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is, but <a data-bg="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/explore.jpg" href="https://elements.envato.com/girls-friends-exploring-outdoors-nature-concept-P3N4J8D" target="_blank">explore</a> those who do not know how to pursue pleasure rationally encounter consequences that are <a data-bg="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/holidays.jpg" href="https://elements.envato.com/a-couple-on-vacation-MERHCT7" target="_blank">holidays</a> painful. 
</div>

<footer class="page-footer">
  <small>Made with <span>❤</span> by <a href="http://georgemartsoukos.com/" target="_blank">George Martsoukos</a>
  </small>
</footer>
/* RESET RULES
–––––––––––––––––––––––––––––––––––––––––––––––––– */
:root {
  --red: firebrick;
  --white: white;
}

* {
  padding: 0;
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

body {
  font: 22px/1.5 sans-serif;
}

h1 {
  text-align: center;
  margin: 20px 0;
}


/* MAIN STYLES
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 10px;
}

.container a {
  position: relative;
  border-bottom: 2px dashed var(--red);
  transition: all 0.2s;
}

.container a::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  min-height: 30px;
  transform: translate(-50%, -50%) scaleX(0);
  padding: 10px;
  z-index: -1;
  transform-origin: 50%;
  background: var(--white);
}

.bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  transition: all 0.3s ease-out;
}

.bg-show .bg {
  z-index: 1;
  opacity: 1;
}

.bg-show a:hover {
  z-index: 2;
  border-bottom-color: transparent;
  color: var(--red);
}

.bg-show .container a:hover::before {
  transform: translate(-50%, -50%) scaleX(1);
  transition: transform 0.2s 0.1s ease-out;
}


/* FOOTER
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.page-footer {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  font-size: 13px;
}

.page-footer span {
  color: var(--red);
}
const links = document.querySelectorAll(".container a");
const bg = document.querySelector(".bg");
const showClass = "bg-show";

for (const link of links) {
  const img = new Image();
  img.src = link.dataset.bg;

  link.addEventListener("mouseenter", function() {
    bg.style.backgroundImage = `url(${this.dataset.bg})`;
    document.body.classList.add(showClass);
  });

  link.addEventListener("mouseleave", () => {
    document.body.classList.remove(showClass);
  });
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.