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

              
                <header>
  <h1>Lorem ipsum dolor sit amet,<br />consectetur adipisicing elit
  </h1>
  <div class="image">
    <img class="visual" src="https://picsum.photos/1200/800" alt="" width="1200" height="800" decoding="async" fetchpriority="high" />
  </div>
</header>
<div class="decorations" aria-hidden="true">
  <div></div>
  <div></div>
  <div></div>
</div>
<section>
  <h2>Loren ipsun dolor sit anet</h2>
  <p>Loren ipsun dolor sit anet, consectetur adipisci elit, sed eiusnod tenpor incidunt ut labore et dolore nagna aliqua. Ut enin ad ninin venian, quis nostrun exercitationen ullan corporis suscipit laboriosan, nisi ut aliquid ex ea connodi consequatur. Quis aute iure reprehenderit in voluptate velit esse cillun dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt nollit anin id est laborun.</p>
</section>
              
            
!

CSS

              
                .visual {
  --_translate: 200px;

  inline-size: 100%;
  block-size: calc(100% + var(--_translate));
  object-fit: cover;
  animation: parallax linear both;
  animation-timeline: scroll(root);
}

.decorations {
  position: relative;
  z-index: -1;
}

.decorations > * {
  position: absolute;
  inset-block-start: calc(var(--_offset-y) * 1dvb);
  inset-inline-start: calc(var(--_offset-x) * 1dvi);
  clip-path: var(--_shape);
  inline-size: max(calc(160 * var(--fluid-ratio)), 80px);
  aspect-ratio: 1;
  background-color: var(--_accent);
  animation: parallax linear both;
  animation-timeline: scroll(root);
}

.decorations > :nth-child(1) {
  --_translate: -100px;
  --_accent: red;
  --_offset-x: 5;
  --_offset-y: 40;
  --_shape: circle(50% at 50% 50%);
}

.decorations > :nth-child(2) {
  --_translate: 100px;
  --_accent: gold;
  --_offset-x: 72;
  --_offset-y: 12;
  --_shape: polygon(
    50% 0%,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
}

.decorations > :nth-child(3) {
  --_translate: -200px;
  --_accent: blue;
  --_offset-x: 15;
  --_offset-y: 60;
  --_shape: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
}

@keyframes parallax {
  from {
    translate: 0 calc(var(--_translate) * -1) 0;
  }

  to {
    translate: 0 var(--_translate) 0;
  }
}

:root {
  --color-light: #f7f8f8;
  --color-dark: #434a56;
  --layout-width: 1280;
  --fluid-ratio: calc(1 / var(--layout-width) * 100dvi);

  background-color: var(--color-light);
  color: var(--color-dark);
}

header {
  --_text-safe-area: calc(120 * var(--fluid-ratio));
  --_padding: max(calc(32 * var(--fluid-ratio)), 32px);

  display: block grid;
  grid-template-columns:
    var(--_padding) [text-start] var(--_text-safe-area)
    [image-start] 1fr [image-end text-end];
  block-size: max(100svb, 480px);
  padding-block: var(--_padding);

  &::after {
    content: "";

    /* 画像のオーバーレイ */
    grid-column: image;
    grid-row: 1;
    background-image: linear-gradient(rgb(0 0 0 / 10%), rgb(0 0 0));
  }
}

header > * {
  grid-row: 1;
}

h1 {
  z-index: 1;
  grid-column: text;
  align-self: center;
  background-image: linear-gradient(
    90deg,
    var(--color-dark) 0% var(--_text-safe-area),
    var(--color-light) var(--_text-safe-area) 100%
  );
  background-clip: text;
  color: transparent;
  font-family: Cinzel, serif;
  font-size: clamp(1.25rem, 0.071rem + 5.24cqi, 4rem);
  font-weight: 400;
}

.image {
  contain: strict;
  z-index: -1;
  grid-column: image;
}

section {
  display: block grid;
  row-gap: 1rlh;
  align-content: center;
  min-block-size: 100svb;
  padding-block: 64px;
  padding-inline: max(5svi, 20px);
}

h2 {
  font-size: clamp(1rem, 0.636rem + 1.82dvi, 2rem);
  text-align: center;
  text-wrap: balance;
}

p {
  max-inline-size: 60rem;
  margin-inline: auto;
}

              
            
!

JS

              
                const lenis = new Lenis();

const raf = (time) => {
  lenis.raf(time);
  requestAnimationFrame(raf);
};

requestAnimationFrame(raf);

              
            
!
999px

Console