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="floor"></div>
  <div class="bowling no1">
    <span class="hole"></span>
  </div>
  
  <div class="motor no1">
    <div class="wheel"></div>
    <div class="mouse">
      <span class="head"></span>
      <span class="leg left"></span>
      <span class="leg right"></span>
    </div>
  </div>
  
  <div class="bowling no2">
    <span class="hole"></span>
  </div>

  <div class="treadmill no1">
    <div class="wheel"></div>
    <span class="foot left"></span>
    <span class="foot right"></span>
    <span class="strap top"></span>
    <span class="strap bottom"></span>
  </div>
  
  <div class="motor no2">
    <div class="wheel"></div>
    <div class="mouse">
      <span class="head"></span>
      <span class="leg left"></span>
      <span class="leg right"></span>
    </div>
  </div>
  
  <div class="treadmill no2">
    <div class="wheel"></div>
    <span class="foot left"></span>
    <span class="foot right"></span>
    <span class="strap top"></span>
    <span class="strap bottom"></span>
  </div>
  
  <div class="bowling no3">
    <span class="hole"></span>
  </div>
  
  <div class="motor no3">
    <div class="wheel"></div>
    <div class="mouse">
      <span class="head"></span>
      <span class="leg left"></span>
      <span class="leg right"></span>
    </div>
  </div>
  
  <div class="treadmill no3">
    <div class="wheel"></div>
    <span class="foot left"></span>
    <span class="foot right"></span>
    <span class="strap top"></span>
    <span class="strap bottom"></span>
  </div>
  
  <div class="basketball">
    <span class="lines"></span>
  </div>
  
  <div class="ramp no1">
    <div class="wood"></div>
  </div>
  <div class="ramp no2">
    <div class="wood"></div>
  </div>
  <div class="panel">
    <span class="wood"></span>
  </div>
  
  <div class="pylon">
    <div class="tube">
      <span class="top"></span>
      <span class="bottom"></span>
    </div>
    <div class="join">
      <div class="circle">
        <span class="top"></span>
      </div>
    </div>
  </div>
</div>

<button class="btn">Démarrer</button>
              
            
!

CSS

              
                :root {
  --bg: #2eb5b8;
  --green: #4AC282;
  --green-dark: #37B074;
  --blue: #2853d6;
  --blue-dark: #1944C5;
  --orange: #C26124;
  --orange-dark: #AB4D24;
  --yellow: #FCF792;
  --yellow-dark: #B1812F;
  --red: #BE3F3F;
  --grey: #dbdbdb;
  --grey-dark: #cacaca;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  background-color: #1E1F26;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.btn {
  background-color: var(--yellow);
  font-size: 2vmin;
  border-radius: 1vmin;
  padding: 1.5vmin 2vmin;
  margin-top: 2.5vmin;
  border: none;
  box-shadow: inset 0 0 0.5vmin var(--yellow-dark);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
  box-shadow: inset 0.25vmin 0.25vmin 0.5vmin var(--yellow-dark);
}

.btn:active {
  transform: translate(0.25vmin, 0.25vmin);
}

.scene {
  position: relative;
  width: 95vmin;
  height: 54vmin;
  background-color: var(--bg);
  box-sizing: content-box;
  border: solid 1.25vmin var(--yellow);
  border-radius: 1.5vmin;
  box-shadow: 0 0 0 0.5vmin var(--yellow-dark);
}

.floor {
  position: absolute;
  bottom: 1vmin;
  right: 2vmin;
  width: 82%;
  height: 3vmin;
  background-color: #be3f3f;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 42 44' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='Page-1' fill='none' fill-rule='evenodd'%3E%3Cg id='brick-wall' fill='%23dbdbdb' %3E%3Cpath d='M0 0h42v44H0V0zm1 1h40v20H1V1zM0 23h20v20H0V23zm22 0h20v20H22V23z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.bowling {
  position: absolute;
  width: 5vmin;
  height: 5vmin;
  background-color: var(--blue);
  border-radius: 50%;
}

.bowling .hole,
.bowling .hole::before,
.bowling .hole::after {
  position: absolute;
  top: 0.75vmin;
  left: 50%;
  width: 0.5vmin;
  height: 0.5vmin;
  border-radius: 50%;
  background-color: #000;
  transform: translateX(-50%);
}

.bowling .hole::before { 
  content: '';
  transform: translateX(-150%); 
}

.bowling .hole::after { 
  content: '';
  transform: translateX(50%); 
}

.bowling.no1 {
  top: 5vmin;
  left: 4vmin;
}

.bowling.no2 {
  top: 35vmin;
  left: 12vmin;
}

.bowling.no3 {
  top: 22.1vmin;
  left: 28.85vmin;
}

/* --- Motor ------------------ */
.motor {
  position: absolute;
  background-color: #4AC282;
  width: 8.25vmin;
}

.motor::before,
.motor::after {
  content: '';
  position: absolute;
  border-radius: 50%;
}

.motor::before {
  top: 0.5vmin;
  right: 0.5vmin;
  width: 1.9vmin;
  height: 1.9vmin;
  background-color: var(--grey);
}

.motor::after {
  top: 0.9vmin;
  right: 0.9vmin;
  width: 1.1vmin;
  height: 1.1vmin;
  background-color: var(--grey-dark);
}

.motor .wheel {
  position: relative;
  width: 3.5vmin;
  height: 3.5vmin;
  background-color: var(--bg);
  border-radius: 50%;
  margin: 0.5vmin;
  border: solid 0.75vmin var(--green-dark);
  box-sizing: content-box;
}

.motor .wheel::before,
.motor .wheel::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4vmin;
  height: 0.75vmin;
  background-color: var(--blue);
  transform: translate(-50%, -50%);
}

.motor .wheel::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.motor.no1 {
  bottom: 8vmin;
  left: 2vmin;
}

.motor.no2 {
  bottom: 14vmin;
  left: 26.2vmin;
}

.motor.no3 {
  bottom: 27vmin;
  left: 43vmin;
}

/* --- Mouse ------------------ */
.mouse {
  position: absolute;
  bottom: 1.25vmin;
  left: 1.5vmin;
  color: #fff;
  background-color: currentColor;
  width: 2vmin;
  height: 1.15vmin;
  border-radius: 0.7vmin;
}

.mouse .head {
  display: block;
  position: absolute;
  bottom: 0;
  right: -0.4vmin;
  background-color: currentColor;
  height: 0.75vmin;
  width: 1.5vmin;
  border-radius: 0.35vmin;
}

.mouse .head::before {
  content: '';
  position: absolute;
  top: -0.75vmin;
  left: 0.1vmin;
  width: 0.2vmin;
  height: 0.6vmin;
  border: solid 0.2vmin currentColor;
  border-radius: 0.2vmin;
  background-color: pink;
}

.mouse .head::after {
  content: '';
  position: absolute;
  top: -0.3vmin;
  right: 0.3vmin;
  width: 0.1vmin;
  height: 0.1vmin;
  background-color: #000;
  border: solid 0.3vmin currentColor;
  border-radius: 50%;
}

.mouse .leg {
  position: absolute;
  top: 70%;
  width: 0; 
  height: 0; 
  border-left: 0.5vmin solid transparent;
  border-right: 0.5vmin solid transparent;
  border-top: 0.75vmin solid currentColor;
}

.mouse .leg.left { left: 0; }
.mouse .leg.right { right: 0; }

.treadmill {
  position: absolute;
  width: 15vmin;
  height: 3vmin;
  background-color: var(--blue);
  border-radius: 1.5vmin;
}

.treadmill::before,
.treadmill::after {
  content: '';
  position: absolute;
  top: 0.5vmin;
  width: 2vmin;
  height: 2vmin;
  background-color: var(--blue-dark);
  border-radius: 50%;
}

.treadmill::before { left: 0.5vmin; }
.treadmill::after { right: 0.5vmin; }

.treadmill .wheel {
  position: absolute;
  top: 0;
  right: 3.5vmin;
  width: 2vmin;
  height: 2vmin;
  border-radius: 50%;
  border: solid 0.5vmin var(--grey-dark);
  box-sizing: content-box;
  z-index: 1;
}

.treadmill .wheel::before,
.treadmill .wheel::after{
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3vmin;
  height: 0.5vmin;
  background-color: var(--grey-dark);
  transform: translate(-50%, -50%);
}

.treadmill .wheel::after { 
  transform: translate(-50%, -50%) rotate(90deg); 
}

.treadmill .foot {
  position: absolute;
  top: 1.5vmin;
  width: 0.5vmin;
  height: 2vmin;
  background-color: var(--grey-dark);
  z-index: 1;
}

.treadmill .foot::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 2vmin;
  height: 0.5vmin;
  background-color: var(--grey-dark);
  transform: translateX(-50%);
}

.treadmill .foot.left { left: 1.25vmin; }
.treadmill .foot.right { right: 1.25vmin; }

.treadmill.no1 {
  bottom: 11vmin;
  left: 11vmin;
}

.treadmill.no2 {
  bottom: 24vmin;
  left: 28vmin;
}

.treadmill.no3 {
  bottom: 37vmin;
  left: 45vmin;
}

/* --- Strap --------------------- */
.strap {
  position: absolute;
  right: 5vmin;
  background-color: #000;
  height: 0.2vmin;
  width: 12vmin;
  transform-origin: 100% 50%;
}

.no1 .strap.top {
  top: 0;
  transform: rotate(-2deg);
}

.no1 .strap.bottom {
  bottom: 0;
  transform: rotate(2deg);
}

.no2 .strap.top {
  top: 0;
  right: 6vmin;
  width: 8.75vmin;
  transform: rotate(-60deg);
}

.no2 .strap.bottom {
  bottom: 0;
  right: 4.5vmin;
  width: 7.5vmin;
  transform: rotate(-52deg);
}

.no3 .strap.top {
  top: 0;
  right: 6vmin;
  width: 8.75vmin;
  transform: rotate(-60deg);
}

.no3 .strap.bottom {
  bottom: 0;
  right: 4.5vmin;
  width: 7.5vmin;
  transform: rotate(-52deg);
}

/* --- Basketball ---------------- */
.basketball {
  position: absolute;
  top: 8vmin;
  left: 46vmin;
  width: 6vmin;
  height: 6vmin;
  background-color: var(--orange);
  border-radius: 50%;
  overflow: hidden;
  z-index: 1;
}

.basketball::before,
.basketball::after {
  content: '';
  position: absolute;
  top: 15%;
  left: 50%;
  width: 50%;
  height: 70%;
  border: solid 0.4vmin var(--orange-dark);
  border-radius: 50%;
}

.basketball::before { transform: translateX(-125%); }
.basketball::after { transform: translateX(25%); }

.basketball .lines,
.basketball .lines::before {
  display: block;
  position: absolute;
  top: 0;
  left: 50%;
  width: 0.4vmin;
  height: 100%;
  background-color: var(--orange-dark);
  transform: translateX(-50%);
}

.basketball .lines::before {
  content: '';
  transform: translateX(-50%) rotate(90deg);
}

.wood {
  position: absolute;
  width: 200%;
  height: 2.5vmin;
  background-color: #C26124;
}

.wood::before {
  content: '';
  position: absolute;
  top: 25%;
  left: 0;
  width: 100%;
  height: 50%;
  background-color: #AB4D24;
}

.ramp {
  position: absolute;
  width: 7vmin;
  height: 10vmin;
  overflow: hidden;
}

.ramp .wood {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(35deg);
}

.ramp.no1 {
  top: 13vmin;
  left: 60.5vmin;
}

.ramp.no2 {
  top: 13vmin;
  left: 75.5vmin;
  transform: scaleX(-1);
}

.panel {
  position: absolute;
  top: 14vmin;
  left: 75vmin;
  width: 17vmin;
  height: 2.5vmin;
  overflow: hidden;
  transform: rotate(90deg);
}

.pylon {
  position: absolute;
  bottom: 4vmin;
  right: 2.2vmin;
  height: 39vmin;
  width: 8vmin;
}

.tube {
  position: absolute;
  bottom: 0;
  right: 1vmin;
  width: 2.5vmin;
  height: 28vmin;
  background-color: var(--grey);
}

.tube::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background-color: var(--grey-dark);
}

.tube .top,
.tube .bottom {
  display: block;
  position: absolute;
  left: 50%;
  width: 130%;
  height: 2.25vmin;
  background-color: var(--grey);
  transform: translateX(-50%)
}

.tube .top::before,
.tube .bottom::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 70%;
  height: 100%;
  background-color: var(--grey-dark);
  border-radius: 0 20% 20% 0;
}

.tube .bottom { bottom: 0; }

.join {
  position: absolute;
  top: 0;
  left: 0;
  width: 7vmin;
  height: 13vmin;
  overflow: hidden;
}

.join .circle {
  position: absolute;
  top: 4.25vmin;
  right: 1.25vmin;
  width: 20vmin;
  height: 20vmin;
  border: solid 1.25vmin var(--grey-dark);
  box-shadow: 0 0 0 1.25vmin var(--grey);
  border-radius: 30%;
}

.circle .top {
  display: block;
  position: absolute;
  top: -3vmin;
  right: 3vmin;
  width: 1.5vmin;
  height: 3.75vmin;
  background-color: var(--grey);
}

.circle .top::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60%;
  background-color: var(--grey-dark);
}
              
            
!

JS

              
                /*
Consignes: https://smnarnold.com/exercices/gsap/gsap-timeline-the-incredible-machine
*/

let anim;

const btn = document.querySelector('.btn');
btn.addEventListener('click', () => anim.play(0));
              
            
!
999px

Console