Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <!-- 
Wall Poster Animation
https://codepen.io/wakana-k/pen/MWZbVxm
Copyright (c) 2023 by Wakana Y.K. @wakana-k
-->

<div id="background">
  <div id="blank"></div>

  <label><input type="radio" name="photo" checked />
    <div class="outer" style="background-image:url(https://images.unsplash.com/photo-1620503374956-c942862f0372?&q=100&dpr=2&w=400);">
      <div class="inner">
        <p>Hello World</p>
      </div>
    </div>
  </label>
  <label><input type="radio" name="photo" />
    <div class="outer" style="background-image:url(https://images.unsplash.com/photo-1543848089-530aad06491a?&q=100&dpr=2&w=400);">
      <div class="inner">
        <p>Lorem Ipsum</p>
      </div>
    </div>
  </label>
  <label><input type="radio" name="photo" />
    <div class="outer" style="background-image:url(https://images.unsplash.com/photo-1550684848-fac1c5b4e853?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2OTQxODQ2NDZ8&ixlib=rb-4.0.3&q=100&dpr=2&w=400);">
      <div class="inner text3">
        <p>ART</p>
      </div>
    </div>
  </label>

  <div id="border"></div>
</div>

<main>
  <section>
    <div>
      <p id='arrow'>&raquo;</p>
    </div>
  </section>
  <section>
    <div>
      <h1>Wall Poster Animation</h1>
    </div>
  </section>
  <section>
    <div>
      <p></p>
    </div>
  </section>
  <section>
    <div>
    </div>
  </section>
  <section>
    <div>
      <h2>Photo credits</h2>
      <p><br></p>
      <ul>
        <li>Kam Idris - <a target="_blank" href="https://unsplash.com/photos/_HqHX3LBN18">brown wooden framed yellow padded chair</a></li>
        <li>Steve Johnson - <a target="_blank" href="https://unsplash.com/photos/4Djs1vdYov4">multicolored abstract painting</a></li>
        <li>Pawel Czerwinski - <a target="_blank" href="https://unsplash.com/photos/vI5XwPbGvmY">white and blue smoke illustration</a></li>
        <li>Rodion Kutsaiev - <a target="_blank" href="https://unsplash.com/photos/pVoEPpLw818">a close up of water droplets on a window</a></li>
      </ul>
      <p><br><b>on <a target="_blank" href="https://unsplash.com/">Unsplash</a>.</b></p>
      <p><br></p>
      <p>Thanks!</p>
    </div>
  </section>
  <section>
    <div>
      <p></p>
    </div>
  </section>
  <section>
    <div>
      <p></p>
    </div>
  </section>
  <footer>
    <a href="https://codepen.io/wakana-k/">@wakana-k</a>
  </footer>
</main>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap");
:root {
  --bg_width: 2000px;
  --bg_height: 1765px;

  --gap_left: 958px;
  --gap_top: 345px;

  --clip_w: 292px;
  --clip_h: 435px;

  --ratio: 0;
  --centerShift_x: calc((100vw - var(--bg_width) * var(--ratio)) / 2);
  --centerShift_y: calc((100vh - var(--bg_height) * var(--ratio)) / 2);
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body,
#background {
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
}
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  font-variant-ligatures: none;
  -webkit-font-variant-ligatures: none;
  text-rendering: optimizeLegibility;
  -moz-osx-font-smoothing: grayscale;
  font-smoothing: antialiased;
  -webkit-font-smoothing: antialiased;
  text-shadow: rgba(0, 0, 0, 0.01) 0 0 1px;
}
body {
  position: relative;
  color: #000;
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-size: 20px;
  font-weight: 400;
  width: 100vw;
  min-height: 100vh;
  text-align: center;
  line-height: 1;
  overflow-x: hidden;
}
#background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-image: url("https://images.unsplash.com/photo-1586023492125-27b2c045efd7?crop=faces,entropy&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2OTQwMTE4Mjl8&ixlib=rb-4.0.3&q=100&w=2000");
  background-size: cover;
  background-position: center;
  z-index: -1;
}
main {
  position: relative;
}
section {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  min-height: 100vh;
  overflow: visible;
}
h1,
h2,
p,
a,
li {
  /*
	text-shadow: -1px -1px 0px rgba(255, 255, 255, 0.8),
		1px 1px 0px rgba(255, 255, 255, 0.8), 1px -1px 0px rgba(255, 255, 255, 0.8),
		-1px 1px 0px rgba(255, 255, 255, 0.8);
*/
  filter: drop-shadow(1px 0px 0px rgba(255, 255, 255, 0.8))
    drop-shadow(0px 1px 0px rgba(255, 255, 255, 0.8))
    drop-shadow(-1px 0px 0px rgba(255, 255, 255, 0.8))
    drop-shadow(0px -1px 0px rgba(255, 255, 255, 0.8));
}
h1 {
  font-size: 33px;
}
h2 {
  font-size: 30px;
}
a {
  color: blue;
  text-decoration: none;
}
ul {
  list-style: none;
  max-width: 80vw;
  overflow-x: hidden;
  overflow-y: visible;
}
li {
  list-style: none;
  font-size: 20px;
  text-align: left;
  margin: 20px 0;
}
li a {
  font-size: 18px;
  filter: unset;
}
p a {
  filter: unset;
}
img,
canvas,
input[type="radio"],
label {
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  pointer-events: none;
}
input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  display: none;
}
#background > * {
  position: absolute;
  top: calc(var(--centerShift_y) + var(--gap_top) * var(--ratio));
  left: calc(var(--centerShift_x) + var(--gap_left) * var(--ratio));
  width: calc(var(--clip_w) * var(--ratio));
  height: calc(var(--clip_h) * var(--ratio));
}
#blank {
  background: white;
}
#border {
  box-shadow: inset 1px 1px 1px rgba(120, 120, 120, 0.1),
    inset -1px -1px 1px rgba(0, 0, 0, 0.1);
}
.outer {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--clip_w) * var(--ratio));
  height: calc(var(--clip_h) * var(--ratio));
  object-fit: cover;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: visible;
  filter: unset;
  opacity: 0;
  transition: opacity 2s;
  background-color: white;
  background-position: center;
  background-size: auto
    calc(max(var(--clip_w), var(--clip_h)) * var(--ratio) * 2); /* 必要に応じて調整 */
  background-repeat: no-repeat;
  will-change: background-position;
  transform: translateZ(0);
}
input:checked + * {
  opacity: 1;
}
.outer * {
  filter: unset;
}
.inner {
  position: relative;
  margin: 3px;
  overflow: hidden;
  color: white;
  font-size: calc(var(--clip_w) * var(--ratio) / 3.5);
  font-weight: 700;
  overflow-wrap: break-word;
  mix-blend-mode: difference;
}
.inner p {
  text-shadow: -0.5px -0.5px 0px rgba(0, 0, 0, 0.3),
    0.5px 0.5px 0px rgba(0, 0, 0, 0.3);
}
.text3 {
  font-size: calc(var(--clip_w) * var(--ratio) / 2.8);
}
#background label:nth-of-type(odd) .outer {
  animation: bg1 8s ease-in-out infinite alternate both;
}
#background label:nth-of-type(even) .outer {
  animation: bg2 9s ease-in-out infinite alternate both;
}
#background label:nth-of-type(3n) .outer {
  animation-direction: alternate-reverse;
}
footer a {
  color: #000;
}
#arrow {
  position: relative;
  top: 40vh;
  left: 8px;
  font-size: 60px;
  font-weight: 400;
  text-shadow: unset;
  transform-origin: center center;
  transform: rotate(90deg);
  animation: arrow 1s ease infinite;
  filter: invert(1);
  mix-blend-mode: difference;
}
@keyframes arrow {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
@keyframes bg1 {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 100% 100%;
  }
}
@keyframes bg2 {
  0% {
    background-position: 100% 0%;
  }
  100% {
    background-position: 0% 100%;
  }
}

              
            
!

JS

              
                /*
Wall Poster Animation
https://codepen.io/wakana-k/pen/MWZbVxm
Copyright (c) 2023 by Wakana Y.K. @wakana-k 
*/
"use strict";
console.clear();

(function () {
  const timer = 3900;

  const root = document.querySelector(":root");
  const bg_width = parseFloat(
    window.getComputedStyle(root).getPropertyValue("--bg_width")
  );
  const bg_height = parseFloat(
    window.getComputedStyle(root).getPropertyValue("--bg_height")
  );

  let items;
  let now = 0;
  let timerId;

  function resize() {
    const ww = window.innerWidth;
    const hh = window.innerHeight;

    // fit size : cover
    let hRatio = ww / bg_width;
    let vRatio = hh / bg_height;
    let ratio = Math.max(hRatio, vRatio);
    root.style.setProperty("--ratio", ratio);
    /*
		// cssで計算した方が早いのでそっちで処理
		let centerShift_x = (ww - bg_width * ratio) / 2;
		let centerShift_y = (hh - bg_height * ratio) / 2;
		root.style.setProperty("--centerShift_x", centerShift_x + "px");
		root.style.setProperty("--centerShift_y", centerShift_y + "px");
		*/
  }
  resize();
  window.onresize = resize;

  function slider() {
    if (now >= items.length) now = 0;
    items[now].checked = true;
    now++;
  }
  window.onload = () => {
    items = document.querySelectorAll("input[name='photo']");
    now++;
    timerId = setInterval(slider, timer);
  };
})();

              
            
!
999px

Console