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

              
                <div class="scene">
  <div class="boardWrapper">
    <div class="boardContainer" data-position="1">
      <div class="boardContainer__board">
        <img src="https://s18.picofile.com/file/8440770792/poster1.jpeg" alt="Poster" />
      </div>
      <div class="boardContainer__board">
        <img src="https://s19.picofile.com/file/8440770800/poster2.jpeg" alt="Poster" />
      </div>
      <div class="boardContainer__board">
        <img src="https://s18.picofile.com/file/8440770826/poster3.jpeg" alt="Poster" />
      </div>
    </div>
    <div class="boardContainer" data-position="2">
      <div class="boardContainer__board">
        <img src="https://s18.picofile.com/file/8440770792/poster1.jpeg" alt="Poster" />
      </div>
      <div class="boardContainer__board">
        <img src="https://s19.picofile.com/file/8440770800/poster2.jpeg" alt="Poster" />
      </div>
      <div class="boardContainer__board">
        <img src="https://s18.picofile.com/file/8440770826/poster3.jpeg" alt="Poster" />
      </div>
    </div>
    <div class="boardContainer" data-position="3">
      <div class="boardContainer__board">
        <img src="https://s18.picofile.com/file/8440770792/poster1.jpeg" alt="Poster" />
      </div>
      <div class="boardContainer__board">
        <img src="https://s19.picofile.com/file/8440770800/poster2.jpeg" alt="Poster" />
      </div>
      <div class="boardContainer__board">
        <img src="https://s18.picofile.com/file/8440770826/poster3.jpeg" alt="Poster" />
      </div>
    </div>
  </div>
  <div class="container">
    <audio loop id="song">
      <source src="https://drive.google.com/uc?export=download&id=1qV7_Qoa9T9ufXZrZudf8K4nzxg9Eg7Hh" />
    </audio>
    <div class="van">
      <div class="roof">
        <div class="windowContainer">
          <div class="windowContainer__window"></div>
        </div>
      </div>
      <div class="body">
        <div class="windowContainer">
          <div class="windowContainer__window"></div>
          <div class="windowContainer__window"></div>
          <div class="windowContainer__window -small"></div>
          <div class="windowContainer__mirror"></div>
        </div>
        <div class="doorContainer">
          <div class="door">
            <div class="door__handle"></div>
          </div>
          <div class="door -small">
            <div class="door__handle"></div>
          </div>
          <div class="gastank"></div>
        </div>
        <div class="underneath">
          <div class="tireContainer -left">
            <span class="tireWrapper">
              <div class="tire">
                <div class="hubcap">
                  <div class="hubcap__hub"></div>
                </div>
              </div>
            </span>
          </div>
          <div class="tireContainer -right">
            <span class="tireWrapper">
              <div class="tire">
                <div class="hubcap">
                  <div class="hubcap__hub"></div>
                </div>
              </div>
            </span>
          </div>

          <div class="underneath__curved -left"></div>
          <div class="underneath__curved -center"></div>
          <div class="underneath__curved -right"></div>

          <div class="badge -left"></div>
          <div class="exhaustCap -left"></div>
          <div class="exhaust">
            <div class="exhaust__part -join"></div>
            <div class="exhaust__part -line"></div>
            <div class="exhaust__part -join"></div>
          </div>

          <div class="shield">
            <div class="header"></div>
            <div class="footer">
              <div class="grilles">
                <div class="grilles__line"></div>
                <div class="grilles__line"></div>
                <div class="grilles__line"></div>
              </div>
              <div class="badge -right"></div>
              <div class="exhaustCap -right"></div>
            </div>
          </div>
        </div>
      </div>

      <div class="trunk">
        <div class="trunk__holder"></div>
        <div class="trunk__tire"></div>
      </div>
    </div>
  </div>
  <footer></footer>
</div>
              
            
!

CSS

              
                :root {
  /* Colors */
  --color-primary: #4d425c;
  --color-gray-light: #b7b7b7;
  --color-gray-dark: #919291;
  --color-yellow: #e9cf53;
  --color-white: #fffadd;
  --color-black: #141018;

  /* Sizes */
  --size-thin: 0.07em;

  /* Borders */
  --border-primary: 0.07em solid #4d425c;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

*::after,
*::before {
  content: "";
  position: absolute;
}

html {
  font-size: 16px;
}

body {
  background-color: var(--color-gray-light);
  overflow-x: hidden;
}

footer {
  width: 100vw;
  border-top: 0.2em solid var(--color-primary);
  height: 9em;
  background-color: var(--color-gray-dark);
}

.scene {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-height: 100vh;
  position: relative;
}

.boardWrapper {
  height: 13em;
  display: flex;
  align-items: flex-start;
  overflow-x: hidden;
}

.boardContainer {
  width: 100vw;
  height: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  overflow-x: hidden;
}

.boardContainer__board {
  width: 12em;
  height: 100%;
  background-color: var(--color-gray-dark);
  flex-shrink: 0;
}

.boardContainer__board img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.van {
  position: relative;
  width: 24em;
  display: flex;
  flex-direction: column;
}

.roof {
  width: 100%;
  height: 3em;
  background-color: var(--color-yellow);
  border-top-right-radius: 2em;
  border-top-left-radius: 2em;
  padding: 0.5em 0.8em 0.15em 0.8em;
  border-bottom: 0.25em solid var(--color-primary);
}

.roof::after,
.roof::before {
  width: 5em;
  height: 0.7em;
  background-color: var(--color-white);
  border-top-right-radius: 1em;
  border-top-left-radius: 1em;
  top: -0.7em;
}

.roof::after {
  right: 4em;
}

.roof::before {
  left: 4em;
}

.roof .windowContainer {
  width: 100%;
  height: 100%;
  border-top-right-radius: 2em;
  border-top-left-radius: 2em;
  background-color: var(--color-white);
  border: var(--border-primary);
  padding: 0.15em 0.25em;
}

.roof .windowContainer .windowContainer__window {
  width: 100%;
  height: 100%;
  background-color: var(--color-primary);
  border-top-right-radius: 2em;
  border-top-left-radius: 2em;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.roof .windowContainer .windowContainer__window::after {
  height: 98%;
  width: 0.7em;
  background-color: var(--color-yellow);
  transform: skewX(-45deg);
}

.body {
  height: 14em;
  width: 100%;
  position: relative;
}

.body > div {
  position: absolute;
  width: 100%;
}

.body .windowContainer {
  height: 4.5em;
  background-color: var(--color-white);
  display: flex;
  align-items: center;
  position: relative;
  z-index: 1;
}

.body .windowContainer .windowContainer__window {
  width: 7.2em;
  height: 2.9em;
  border: 0.2em solid var(--color-yellow);
  border-radius: 1em;
  background-color: var(--color-primary);
}

.body .windowContainer .windowContainer__window:first-child {
  margin-left: 0.6em;
}

.body .windowContainer .windowContainer__window:nth-child(2) {
  margin-left: 1.8em;
  margin-right: 1.31em;
}

.body .windowContainer .windowContainer__window.-small {
  width: 3.2em;
}

/* .body .windowContainer::after {
  width: 0.25em;
  height: 100%;
  right: 0em;
  transform: rotate(-3deg);
  transform-origin: center top;
  background-color: red;
} */

.body .windowContainer .windowContainer__mirror {
  position: absolute;
  height: 1.7em;
  width: 0.35em;
  background-color: var(--color-yellow);
  right: 0.5em;
  border-radius: 1.5em;
  bottom: 0.5em;
}

.body .windowContainer .windowContainer__mirror::before {
  height: 1.4em;
  width: 0.35em;
  background-color: var(--color-primary);
  left: -0.1em;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 1.2em;
  z-index: -1;
}

.body .windowContainer .windowContainer__mirror::after {
  width: 0.4em;
  height: 0.4em;
  border-radius: 100%;
  border: var(--border-primary);
  bottom: 0.3em;
  z-index: -1;
  left: 0;
}

.body .doorContainer {
  height: 7.5em;
  background-color: var(--color-yellow);
  z-index: 1;
  position: absolute;
}

.body .doorContainer > div {
  position: absolute;
}

.body .doorContainer .door {
  width: 9em;
  height: 10em;
  border: var(--border-primary);
  z-index: 2;
  left: 37%;
  top: -4.1em;
  border-radius: 1em;
  border-top-right-radius: 0;
}

.body .doorContainer .door.-small {
  width: 3.7em;
  height: 8.5em;
  border: var(--border-primary);
  border-left: 0;
  border-radius: 0;
  border-top-right-radius: 1em;
  border-bottom-right-radius: 10em;
  left: 74.5%;
  top: -4.1em;
  z-index: 2;
}

.body .doorContainer .door .door__handle {
  width: 1em;
  height: 0.7em;
  position: absolute;
  right: 15%;
  top: calc(10em * 50 / 100);
  border: var(--border-primary);
  border-bottom-right-radius: 100%;
  border-bottom-left-radius: 100%;
}

.body .doorContainer .door.-small .door__handle {
  top: calc(10em * 50 / 100);
  left: 15%;
}

.body .doorContainer .door:first-child::before {
  width: 6em;
  height: var(--size-thin);
  background-color: var(--color-primary);
  top: 50%;
  transform: translateY(-50%);
  left: -6.05em;
}

.body .doorContainer .gastank {
  width: 1em;
  height: 1em;
  border: var(--border-primary);
  z-index: 2;
  left: calc(10% - 0.5em);
  bottom: 50%;
  border-radius: 100%;
}

.body .tireContainer .tireWrapper {
  position: relative;
  z-index: 2;
  left: -44%;
}

.body .tireContainer .tireWrapper .tire {
  width: 3.5em;
  height: 3.5em;
  border-radius: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--color-black);
  position: absolute;
}

.body .tireContainer.-right .tireWrapper .tire::before {
  top: -0.5em;
}

.body .tireContainer.-left .tireWrapper .tire::before {
  top: -0.5em;
}

.body .tireContainer .tireWrapper .tire::before {
  --size: 4em;

  width: var(--size);
  height: calc(var(--size) / 2);
  background-color: var(--color-primary);
  z-index: -1;
  border-top-left-radius: calc(var(--size) * 2);
  border-top-right-radius: calc(var(--size) * 2);
}

.body .tireContainer .tireWrapper .tire .hubcap {
  width: 1.5em;
  height: 1.5em;
  border-radius: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--color-white);
}

.body .tireContainer .tireWrapper .tire .hubcap .hubcap__hub {
  width: 0.8em;
  height: 0.8em;
  border-radius: 100%;
  background-color: var(--color-primary);
  position: relative;
}

.body .tireContainer .tireWrapper .tire .hubcap .hubcap__hub::after,
.body .tireContainer .tireWrapper .tire .hubcap .hubcap__hub::before {
  width: 0.15em;
  height: 1em;
  background-color: var(--color-primary);
  border-radius: 2em;
  left: 50%;
  transform: translateX(-50%);
}

.body .tireContainer .tireWrapper .tire .hubcap .hubcap__hub::after {
  top: -10%;
}

.body .tireContainer .tireWrapper .tire .hubcap .hubcap__hub::before {
  bottom: -10%;
}

.trunk {
  position: absolute;
  left: 0;
  z-index: 3;
  bottom: 30%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  left: -0.7em;
}

.trunk .trunk__holder {
  width: 0.7em;
  height: 3.6em;
  background-color: var(--color-primary);
}

.trunk .trunk__tire {
  width: 2.3em;
  height: 5.5em;
  background-color: var(--color-white);
  border-radius: calc(2.3em / 2);
  position: absolute;
  right: 0.7em;
  top: -0.95em;
}

.trunk .trunk__tire::after {
  width: var(--size-thin);
  height: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-primary);
}

.underneath {
  height: 3.5em;
  position: absolute;
  bottom: 0;
  z-index: 2;
}

.underneath > div {
  position: absolute;
}

.underneath .underneath__curved {
  height: 0.5em;
  background-color: var(--color-yellow);
  border-bottom-left-radius: 1em;
  border-bottom-right-radius: 1em;
}

.underneath .underneath__curved.-center {
  width: 45.5%;
  left: 31.7%;
  top: 1.4em;
}

.underneath .underneath__curved.-left {
  left: 0;
  width: 15%;
  top: 1.4em;
}

.underneath .underneath__curved.-right {
  right: 0;
  width: 6%;
  top: 1.4em;
  border-bottom-right-radius: 0;
}

.underneath .tireContainer {
  width: 4em;
  height: 4em;
  display: flex;
  justify-content: center;
}

.underneath .tireContainer.-left {
  left: 15%;
}

.underneath .tireContainer.-right {
  right: 6%;
}

.underneath .badge.-left {
  width: 0.4em;
  height: 1.4em;
  background-color: var(--color-primary);
  top: -0.8em;
}

.underneath .badge.-left::after {
  right: -0.3em;
  width: 0.3em;
  height: 1.4em;
  background-color: var(--color-white);
  top: 0;
}

.underneath .exhaustCap {
  height: 1em;
  background-color: var(--color-white);
  bottom: 1.35em;
  border-radius: 0.7em;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2;
}

.underneath .exhaustCap.-left {
  left: -0.5em;
  width: 3.5em;
}

.underneath .exhaustCap::after {
  width: 100%;
  height: var(--size-thin);
  background-color: var(--color-yellow);
}

.underneath .exhaust {
  width: 2.5em;
  height: 0.5em;
  bottom: 0.85em;
  border-radius: 0.7em;
  display: flex;
  justify-content: center;
  align-items: center;
  left: -0.5em;
}

.underneath .exhaust .exhaust__part {
  background-color: var(--color-black);
  position: absolute;
}

.underneath .exhaust .exhaust__part.-join:first-child {
  width: 0.3em;
  height: 0.45em;
  border-bottom-right-radius: 1em;
  background-color: var(--color-black);
  right: 0;
  top: 0;
}

.underneath .exhaust .exhaust__part.-line {
  width: 1.5em;
  height: 0.3em;
  border-bottom-right-radius: 1em;
  background-color: var(--color-black);
  bottom: 0.05em;
  right: 0;
}

.underneath .exhaust .exhaust__part.-join:last-child {
  width: 0.3em;
  height: 0.45em;
  border-bottom-left-radius: 1em;
  border-bottom-right-radius: 1em;
  background-color: var(--color-black);
  top: 0.2em;
  right: 1.2em;
}

.underneath .shield {
  width: 2em;
  height: 7.9em;
  right: -2em;
  bottom: calc(2em - 0.4em);
  border-bottom-right-radius: 0.5em;
  background-color: var(--color-yellow);
}

.underneath .shield .header {
  position: absolute;
  width: 100%;
  height: 3.5em;
  top: 0;
  left: 0;
  background-color: var(--color-gray-light);
  border-left: var(--border-primary);
  border-bottom: var(--border-primary);
  border-bottom-left-radius: 0.7em;
}

.underneath .shield .header::after {
  width: 100%;
  height: 2em;
  background-color: var(--color-yellow);
  bottom: 0;
  border-bottom-left-radius: 0.7em;
  border-top-right-radius: 100%;
}

.underneath .shield .footer {
  position: absolute;
  width: 100%;
  height: calc(7.9em - 3.5em);
  bottom: 0;
  left: 0;
}

.underneath .shield .footer .grilles {
  width: 1.1em;
  height: 0.7em;
  transform: rotate(45deg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: absolute;
  bottom: 1.7em;
}

.underneath .shield .footer .grilles .grilles__line {
  width: 100%;
  height: var(--size-thin);
  background-color: var(--color-primary);
}

.underneath .shield .footer .badge.-right {
  position: absolute;
  width: 0.25em;
  height: 1.6em;
  background-color: var(--color-white);
  right: 0;
  bottom: 1.3em;
}

.underneath .shield .footer .exhaustCap.-right {
  position: absolute;
  right: -0.5em;
  width: 2.3em;
  bottom: -0.3em;
}

@media screen and (min-width: 1000px) {
  html {
    font-size: 22px;
  }
}

@media (max-width: 900px) {
  html {
    font-size: 87.5%;
  }
}

@media (max-width: 680px) {
  html {
    font-size: 81.25%;
  }
  .boardContainer__board {
    width: 9em;
  }
}
              
            
!

JS

              
                // Inspired by:
// https://dribbble.com/shots/6736945-The-Bumpy-Mobile

const ARROW_RIGHT_KEY = "ArrowRight";
const ARROW_LEFT_KEY = "ArrowLeft";

const van = document.querySelector(".van"),
  boards = document.querySelectorAll(".boardContainer"),
  initialActiveBoard = 2,
  songEl = document.getElementById("song");

let isAnimating = false,
  deltaX = window.innerWidth,
  everPlayedTheAnimation = false;

const BoardsSlider = {
  currentActiveBoard: initialActiveBoard,
  boardTl: new TimelineLite(),
  init() {
    [...boards].forEach((element, index) => {
      element.style.order = index + 1;
    });
  },
  moveBoard() {
    const that = this;

    this.boardTl.to(".boardWrapper", 5, {
      x: -deltaX,
      ease: Linear.easeNone,
      onComplete() {
        that.changeOrder();
        that.moveBoard();
      },
    });
  },
  stop() {
    this.boardTl.pause();
  },
  resume() {
    this.boardTl.resume();
  },
  changeOrder() {
    if (this.currentActiveBoard === boards.length) {
      this.currentActiveBoard = initialActiveBoard;
    } else {
      this.currentActiveBoard++;
    }

    let order = 1;

    // Change order from current position till last
    for (let i = this.currentActiveBoard; i <= boards.length; i++) {
      document.querySelector(
        `.boardContainer[data-position='${i}']`
      ).style.order = order;
      order++;
    }

    // Change order from first position till current
    for (let i = 1; i < this.currentActiveBoard; i++) {
      document.querySelector(
        `.boardContainer[data-position='${i}']`
      ).style.order = order;
      order++;
    }

    TweenLite.set(".boardWrapper", {
      x: 0,
    });
  },
};

const Van = {
  vanTl: new TimelineLite({ repeat: -1 }),
  hubCapsTl: new TimelineLite({ repeat: -1 }),
  run() {
    this.hubCapsTl.to(".hubcap", 5, {
      rotation: 360,
      ease: Linear.easeNone,
    });
    this.vanTl
      .to(
        ".van",
        2,
        {
          rotation: -1.5,
          x: 45
        },
        "<"
      )
      .to(
        ".tireContainer.-right .tireWrapper",
        2,
        {
          y: 7,
        },
        "<"
      )
      .to(
        CSSRulePlugin.getRule(
          ".body .tireContainer.-right .tireWrapper .tire::before"
        ),
        2,
        {
          cssRule: {
            translateY: -5,
          },
        },
        "<"
      )
      .to(
        ".van",
        2,
        {
          rotation: 0,
          x: 0,
        }
      )
      .to(
        ".tireContainer.-right .tireWrapper",
        2,
        {
          y: 0,
        },
        "<"
      )
      .to(
        CSSRulePlugin.getRule(
          ".body .tireContainer.-right .tireWrapper .tire::before"
        ),
        2,
        {
          cssRule: {
            translateY: 0,
          },
        },
        "<"
      );
  },
  stop() {
    this.vanTl.pause();
    this.hubCapsTl.pause();
  },
  resume() {
    this.vanTl.resume();
    this.hubCapsTl.resume();
  },
};

const Song = {
  play() {
    songEl.play();
  },
  pause() {
    songEl.pause();
  },
};

BoardsSlider.init();

const App = {
  run() {
    everPlayedTheAnimation = true;
    isAnimating = true;

    Song.play();
    BoardsSlider.moveBoard();
    Van.run();
  },
  stop() {
    isAnimating = false;

    Song.pause();
    BoardsSlider.stop();
    Van.stop();
  },
  resume() {
    isAnimating = true;

    Song.play();
    BoardsSlider.resume();
    Van.resume();
  },
};

// window.addEventListener("keydown", ({ key }) => {
//   const shouldAnimate = key === ARROW_RIGHT_KEY;
//   if (!shouldAnimate) return;

//   if (everPlayedTheAnimation) {
//     App.resume();
//   } else {
//     App.run();
//   }
// });

// window.addEventListener("keyup", () => {
//   App.stop();
// });

window.addEventListener("resize", () => {
  deltaX = window.innerWidth;
});

window.addEventListener("load", () => {
  setTimeout(() => {
    swal("Looking for some stress-relief?", "Hit the road! Make sure you have your volume turned up as well.", {
      button: "Let's go!"
    })
    .then(() => {
      App.run()
    })
  }, 1000)
});

              
            
!
999px

Console