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

              
                <main>
      <div class="track">
        <div class="title-trigger">
          <div class="title">
            <h1><span>Tokyo</span><span>Scroll</span></h1>
          </div>
        </div>
        <div class="car brian">
          <img
            class="brian__img"
            src="https://assets.codepen.io/605876/brian-o-conner.svg"
            alt=""
          />
          <!-- Such a hack. But put everything inside the car... -->
          <div class="indicators">
            <div class="progress progress--entry">
              <div class="progress__bar"></div>
              <div class="progress__label">
                <div class="progress__label-text">entry</div>
                <div class="progress__label-progress"></div>
              </div>
            </div>
            <div class="progress progress--entry-crossing">
              <div class="progress__bar"></div>
              <div class="progress__label">
                <div class="progress__label-text">entry-crossing</div>
                <div class="progress__label-progress"></div>
              </div>
            </div>
            <div class="progress progress--exit">
              <div class="progress__bar"></div>
              <div class="progress__label">
                <div class="progress__label-text">exit</div>
                <div class="progress__label-progress"></div>
              </div>
            </div>
            <div class="progress progress--exit-crossing">
              <div class="progress__bar"></div>
              <div class="progress__label">
                <div class="progress__label-text">exit-crossing</div>
                <div class="progress__label-progress"></div>
              </div>
            </div>
            <div class="progress progress--cover">
              <div class="progress__bar"></div>
              <div class="progress__label">
                <div class="progress__label-text">cover</div>
                <div class="progress__label-progress"></div>
              </div>
            </div>
            <div class="progress progress--contain">
              <div class="progress__bar"></div>
              <div class="progress__label">
                <div class="progress__label-text">contain</div>
                <div class="progress__label-progress"></div>
              </div>
            </div>
            <div class="progress progress--dom">
              <div class="progress__bar"></div>
              <div class="progress__label">
                <div class="progress__label-text">dom toretto</div>
                <div class="progress__label-progress"></div>
              </div>
            </div>
            <div class="action">
              <label for="dom">
                <img src="https://assets.codepen.io/605876/dom.png" alt="" />
                <span class="sr-only">Show Dom</span>
              </label>
              <input id="dom" type="checkbox" />
            </div>
          </div>
          <div class="dom-track">
            <img
              class="car dom"
              src="https://assets.codepen.io/605876/dom-toretto.svg"
              alt=""
            />
          </div>
        </div>
        <div class="surround"></div>
      </div>
    </main>
              
            
!

CSS

              
                @import "https://unpkg.com/normalize.css" layer(normalize);
@import "https://unpkg.com/open-props/open-props.min.css" layer(open-props);
@import "https://unpkg.com/open-props/normalize.min.css" layer(open-props);

*,
*:after,
*:before {
  box-sizing: border-box;
  max-inline-size: 100%;
}

body {
  display: grid;
  place-items: center;
  height: 100vh;
  overflow: hidden;
  background: var(--gray-4);
  font-family:  'Google Sans', sans-serif, system-ui;
}

:root {
  --track-size: 40vw;
  --track-translation: 10%;
}

main {
  width: var(--track-size);
  aspect-ratio: 4 / 3;
  overflow: auto;
  position: relative;
  background:
    repeating-linear-gradient(0deg, white 0 10%, transparent 10% 15%) 50% 0 / 10px 100% no-repeat,
    linear-gradient(var(--gray-8), var(--gray-8)) 50% 0 / calc(var(--track-size) * 0.3) 100% no-repeat,
    linear-gradient(90deg, var(--green-8) 25%, transparent 25% 75%, var(--green-8) 75%),
    var(--gray-6);
}

.title {
  width: var(--track-size);
  aspect-ratio: 4 / 3;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: grid;
  place-items: center;
  background: hsl(0 0% 0% / 0.75);
}

.title h1 {
  color: var(--gray-0);
  display: grid;
  font-family: 'Impact', sans-serif;
  text-transform: uppercase;
  margin: 0;
  line-height: 1;
  transform: skewX(-10deg);
}

.title h1 span {
  clip-path: inset(0 0 0 0);
}

.title h1 span:first-of-type {
  animation: auto stage-left linear both;
  animation-timeline: --title;
  animation-time-range: exit;
}

.title h1 span:last-of-type {
  animation: auto stage-right linear both;
  animation-timeline: --title;
  animation-range: exit;
}

@keyframes stage-left {
  to {
    left: 0;
    clip-path: inset(0 100% 0 0);
  }
}

@keyframes stage-right {
  to {
    left: 0;
    clip-path: inset(0 0 0 100%);
  }
}

.title-trigger {
  width: 100%;
  aspect-ratio: 4 / 3;
  view-timeline-name: --title;
  margin-top: 100%;
}

.title {
  animation: auto fade both linear;
  animation-timeline: --title;
  animation-range: exit;
}

@keyframes fade {
  to {
    background: hsl(0 0% 0% / 0);
  }
}

.surround {
  --border: 25px;
  width: calc(var(--track-size) + (2 * var(--border)));
  height: calc(var(--track-size) * 0.75 + (2 * var(--border)));
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border: var(--border) solid var(--gray-8);
}

.surround:before {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: 0 0 10px 10px hsl(0 0% 0% / 0.5) inset;
  background: linear-gradient(55deg, transparent 25%, hsl(0 0% 100% / 0.25) 65%, transparent 90%);
}

.surround:after {
  content: "";
  width: calc(var(--border) * 0.75);
  aspect-ratio: 3/1;
  background: var(--red-5);
  position: absolute;
  bottom: calc(var(--border) * -0.5);
  transform: translate(-100%, 150%);
  right: 0;
  box-shadow: 0 0 8px 4px hsl(0 100% 50% / 0.5);
}

.track {
	view-timeline-root: --brian;
  height: 500%;
  width: 100%;
  position: relative;
}

.road {
  width: calc(var(--track-size) * 0.3);
  background: repeating-linear-gradient(0deg, white 0 10%, transparent 10% 15%) 50% 0 / 10px 100% no-repeat,
    var(--gray-8);
  height: 100%;
  position: absolute;
  left: 50%;
  transform: translate(-50%, 0);
}

.car {
  width: calc(var(--track-size) * 0.1);
  position: absolute;
  left: 50%;
  object-fit: contain;
}

.brian {
	width: calc(var(--track-size) * 0.1);
  position: absolute;
  left: 50%;
  aspect-ratio: 100 / 178;
  top: 50%;
  margin-left: calc(var(--track-size) * -0.1285);
  view-timeline: --brian;
}

.brian__img {
	width: 100%;
}

.dom-track {
  position: fixed;
  width: var(--track-size);
  aspect-ratio: 4 / 3;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  overflow: hidden;
}

.action {
  display: flex;
  place-items: center;
  gap: 0.5rem;
}
label {
  color: var(--gray-9);
}

:root:has(#dom:checked) .dom {
  opacity: 1;
}

.progress--dom {
  display: none;
}

:root:has(#dom:checked) .progress--dom {
  display: block;
}

:root:has(#dom:checked) .dom {
  opacity: 1;
}

.dom {
  bottom: 0;
  width: calc(var(--track-size) * 0.12);
  transform: translateX(22%) translateY(150%);
  animation: auto family both linear;
  animation-timeline: --brian;
  animation-range: cover 10% cover 65%;
  opacity: 0;
}

@keyframes family {
  to {
    left: 50%;
    transform: translateX(22%) translateY(calc(150% - (var(--track-size) * 0.75) - 150%));
  }
}

.indicators {
  position: fixed;
  width: 16vw;
  left: 8vw;
  display: grid;
  top: 50%;
  gap: 2rem;
  transform: translate(0, -50%);
  justify-items: center;
}

.progress {
  height: 2.5rem;
  width: 100%;
  background: var(--gray-8);
  position: relative;
  border-radius: var(--radius-3);
  overflow: hidden;
}

.progress__bar {
  background: var(--indigo-6);
  width: 100%;
  height: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.progress:nth-of-type(even) .progress__bar {
  background: var(--orange-6);
}

.progress__label {
  position: absolute;
  inset: 0;
  text-align: center;
  font-weight: bold;
  display: flex;
  grid-auto-flow: column;
  place-items: center;
  font-size: 1.25rem;
  color: var(--gray-0);
  padding: 0 0.5rem;
}

.progress__label-text {
  flex: 1;
}

@property --e {
  inherit: false;
  initial-value: 0;
  syntax: '<integer>';
}
@property --milliseconds {
  inherits: false;
  initial-value: 0;
  syntax: '<integer>';
}
.progress__label-progress {
  counter-reset: ms var(--milliseconds);
  animation: auto bump steps(100,end) both;
  animation-timeline: --brian;
}
.progress__label-progress:after {
  content: counter(ms)'%';
  font-variant: tabular-nums;
}

.progress--entry .progress__label-progress {
  animation-range: entry;
}
.progress--entry-crossing .progress__label-progress {
  animation-range: entry-crossing;
}
.progress--exit .progress__label-progress {
  animation-range: exit;
}
.progress--exit-crossing .progress__label-progress {
  animation-range: exit-crossing;
}
.progress--dom .progress__label-progress {
  animation-range: cover 15% cover 65%;
}
.progress--cover .progress__label-progress {
  animation-range: cover;
}
.progress--contain .progress__label-progress {
  animation-range: contain;
}

@keyframes bump {
  to {
    --milliseconds: 100;
  }
}

.progress--scroll .progress__bar {
  animation: auto indicate both linear;
  animation-timeline: scroll();
}
.progress--dom .progress__bar {
  animation: auto indicate both linear;
  animation-timeline: --brian;
  animation-range: cover 15% cover 65%;
}
.progress--entry-crossing .progress__bar {
  animation: auto indicate both linear;
  animation-timeline: --brian;
  animation-range: entry-crossing;
}
.progress--entry .progress__bar {
  animation: auto indicate both linear;
  animation-timeline: --brian;
  animation-range: entry;
}
.progress--exit .progress__bar {
  animation: auto indicate both linear;
  animation-timeline: --brian;
  animation-range: exit;
}
.progress--exit-crossing .progress__bar {
  animation: auto indicate both linear;
  animation-timeline: --brian;
  animation-range: exit;
}
.progress--cover .progress__bar {
  animation: auto indicate both linear;
  animation-timeline: --brian;
  animation-range: cover;
}
.progress--contain .progress__bar {
  animation: auto indicate both linear;
  animation-timeline: --brian;
  animation-range: contain;
}

@keyframes indicate {
  to {
    left: 0;
    transform: scaleX(1);
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console