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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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="table">
  <div class="shader"></div>
  <div class="pot1"></div>
  <div class="pot2"></div>
  <div class="pot3"></div>
  <div class="pot4"></div>
  <div class="pot5"></div>
  <div class="pot6"></div>
  <div class="cue-ball"></div>
  <div class="cue"></div>
  <div data-num="1" class="ball1"></div>
  <div data-num="2" class="ball2"></div>
  <div data-num="3" class="ball3"></div>
  <div data-num="4" class="ball4"></div>
  <div data-num="5" class="ball5"></div>
  <div data-num="6" class="ball6"></div>
  <div data-num="7" class="ball7"></div>
  <div data-num="8" class="ball8"></div>
  <div data-num="9" class="ball9"></div>
  <div data-num="10" class="ball10"></div>
</div>
              
            
!

CSS

              
                body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.table {
  width: 620px;
  height: 320px;
  background-color: rgba(33, 22, 0, 1);
  background: linear-gradient(
    rgba(238, 196, 135, 0.5) 0%,
    rgba(243, 207, 154, 0.5) 3%,
    rgba(248, 216, 162, 0.5) 6%,
    rgba(243, 207, 154, 0.5) 6%,
    rgba(243, 207, 154, 0.5) 9%,
    rgba(241, 202, 136, 0.5) 12%,
    rgba(243, 207, 154, 0.5) 15%,
    rgba(244, 208, 158, 0.5) 17%,
    rgba(243, 207, 154, 0.5) 19%,
    rgba(243, 207, 154, 0.5) 21%,
    rgba(250, 221, 176, 0.5) 23%,
    rgba(250, 221, 176, 0.5) 25%,
    rgba(243, 207, 154, 0.5) 27%,
    rgba(238, 200, 138, 0.5) 29%,
    rgba(243, 207, 154, 0.5) 29%,
    rgba(243, 207, 154, 0.5) 32%,
    rgba(243, 207, 154, 0.5) 34%,
    rgba(243, 207, 154, 0.5) 37%,
    rgba(250, 221, 176, 0.5) 40%,
    rgba(250, 221, 176, 0.5) 43%,
    rgba(243, 207, 154, 0.5) 43%,
    rgba(243, 207, 154, 0.5) 44%,
    rgba(243, 207, 154, 0.5) 47%,
    rgba(238, 200, 138, 0.5) 49%,
    rgba(243, 207, 154, 0.5) 52%,
    rgba(250, 221, 176, 0.5) 54%,
    rgba(244, 208, 158, 0.5) 56%,
    rgba(243, 207, 154, 0.5) 59%,
    rgba(244, 208, 158, 0.5) 61%,
    rgba(250, 221, 176, 0.5) 64%,
    rgba(243, 207, 154, 0.5) 64%,
    rgba(244, 208, 158, 0.5) 66%,
    rgba(243, 207, 154, 0.5) 69%,
    rgba(248, 216, 162, 0.5) 71%,
    rgba(243, 207, 154, 0.5) 74%,
    rgba(243, 207, 154, 0.5) 76%,
    rgba(243, 207, 154, 0.5) 77%,
    rgba(243, 207, 154, 0.5) 80%,
    rgba(250, 221, 176, 0.5) 81%,
    rgba(243, 207, 154, 0.5) 83%,
    rgba(250, 221, 176, 0.5) 83%,
    rgba(250, 221, 176, 0.5) 85%,
    rgba(243, 207, 154, 0.5) 87%,
    rgba(250, 221, 176, 0.5) 89%,
    rgba(250, 221, 176, 0.5) 91%,
    rgba(243, 207, 154, 0.5) 92%,
    rgba(248, 216, 162, 0.5) 96%,
    rgba(243, 207, 154, 0.5) 97%,
    rgba(243, 207, 154, 0.5) 97%,
    rgba(243, 207, 154, 0.5) 98%,
    rgba(243, 207, 154, 0.5) 100%
  );
  background-size: 500px 20px, 300px 20px, 20px 820px;
  background-position: 50% 50%, 70% 70%, 30% 30%;
  border-radius: 8px;
  position: relative;
}

.shader {
  z-index: 2;
  width: 100%;
  height: 100%;
  background-color: #0000004f;
  border-radius: 8px;
}

.table::before {
  content: "";
  z-index: 4;
  position: absolute;
  top: 32px;
  left: 32px;
  background-color: #1e4d0e;
  width: calc(100% - 64px);
  height: calc(100% - 64px);
  box-shadow: inset 0px 0px 34px 1px #006900;
}

.table::after {
  content: "";
  z-index: 6;
  position: absolute;
  top: 43px;
  left: 43px;
  background-color: green;
  width: calc(100% - 86px);
  height: calc(100% - 86px);
  box-shadow: inset 0px 0px 12px 2px rgba(0, 0, 0, 0.4);
}

.pot1 {
  position: absolute;
  top: 22px;
  z-index: 10;
  left: 22px;
  width: 36px;
  height: 36px;
  background-color: black;
  border-radius: 50%;
  box-shadow: inset 2px 2px 0 0 #6f5b40;
}

.pot2 {
  position: absolute;
  top: 16px;
  z-index: 10;
  left: 292px;
  width: 34px;
  height: 34px;
  background-color: black;
  border-radius: 50%;
  box-shadow: inset 0px 3px 0 0 #6f5b40;
}

.pot3 {
  position: absolute;
  top: 22px;
  z-index: 10;
  right: 22px;
  width: 36px;
  height: 36px;
  background-color: black;
  border-radius: 50%;
  box-shadow: inset -2px 2px 0 0 #6f5b40;
}

.pot4 {
  position: absolute;
  bottom: 22px;
  z-index: 10;
  left: 22px;
  width: 36px;
  height: 36px;
  background-color: black;
  border-radius: 50%;
  box-shadow: inset 2px -2px 0 0 #6f5b40;
}

.pot5 {
  position: absolute;
  bottom: 16px;
  z-index: 10;
  left: 292px;
  width: 34px;
  height: 34px;
  background-color: black;
  border-radius: 50%;
  box-shadow: inset 0px -3px 0 0 #6f5b40;
}

.pot6 {
  position: absolute;
  bottom: 22px;
  z-index: 10;
  right: 22px;
  width: 36px;
  height: 36px;
  background-color: black;
  border-radius: 50%;
  box-shadow: inset -2px -2px 0 0 #6f5b40;
}

.cue {
  position: absolute;
  top: 53%;
  left: -220px;
  z-index: 12;
  width: 300px;
  height: 7px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 1) 30%,
    #b9901c 30%,
    #b9901c 96%,
    rgba(255, 255, 255, 0.9) 96%,
    #01579b 100%
  );
  border-radius: 70% 50% 50% 70% / 0% 50% 50% 0%;
}

.cue-ball {
  z-index: 12;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: white;
  position: absolute;
  left: 150px;
  top: 50%;
  box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.5);
}

.ball1 {
  z-index: 12;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background-color: white;
  position: absolute;
  right: 200px;
  top: 50%;
  box-shadow: inset 0px 0px 0px 5px #ffc107, 2px 2px 4px 0 rgba(0, 0, 0, 0.4);
}

.ball1::before {
  content: attr(data-num);
  font-size: 12px;
  width: 100%;
  height: 100%;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ball2 {
  z-index: 12;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background-color: white;
  position: absolute;
  right: 174px;
  top: 54%;
  box-shadow: inset 0px 0px 0px 5px #2196f3, 2px 2px 4px 0 rgba(0, 0, 0, 0.4);
}

.ball2::before {
  content: attr(data-num);
  font-size: 12px;
  width: 100%;
  height: 100%;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ball3 {
  z-index: 12;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background-color: white;
  position: absolute;
  right: 174px;
  top: 46%;
  box-shadow: inset 0px 0px 0px 5px #f44336, 2px 2px 4px 0 rgba(0, 0, 0, 0.4);
}

.ball3::before {
  content: attr(data-num);
  font-size: 12px;
  width: 100%;
  height: 100%;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ball4 {
  z-index: 12;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background-color: white;
  position: absolute;
  right: 150px;
  top: 58%;
  box-shadow: inset 0px 0px 0px 5px #9c27b0, 2px 2px 4px 0 rgba(0, 0, 0, 0.4);
}

.ball4::before {
  content: attr(data-num);
  font-size: 12px;
  width: 100%;
  height: 100%;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ball5 {
  z-index: 12;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background-color: white;
  position: absolute;
  right: 150px;
  top: 50%;
  box-shadow: inset 0px 0px 0px 5px #ff9800, 2px 2px 4px 0 rgba(0, 0, 0, 0.4);
}

.ball5::before {
  content: attr(data-num);
  font-size: 12px;
  width: 100%;
  height: 100%;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ball6 {
  z-index: 12;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background-color: white;
  position: absolute;
  right: 150px;
  top: 42%;
  box-shadow: inset 0px 0px 0px 5px #4caf50, 2px 2px 4px 0 rgba(0, 0, 0, 0.4);
}

.ball6::before {
  content: attr(data-num);
  font-size: 12px;
  width: 100%;
  height: 100%;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ball7 {
  z-index: 12;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background-color: white;
  position: absolute;
  right: 126px;
  top: 62%;
  box-shadow: inset 0px 0px 0px 5px #6d4c41, 2px 2px 4px 0 rgba(0, 0, 0, 0.4);
}

.ball7::before {
  content: attr(data-num);
  font-size: 12px;
  width: 100%;
  height: 100%;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ball8 {
  z-index: 12;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background-color: white;
  position: absolute;
  right: 126px;
  top: 54%;
  box-shadow: inset 0px 0px 0px 5px #424242, 2px 2px 4px 0 rgba(0, 0, 0, 0.4);
}

.ball8::before {
  content: attr(data-num);
  font-size: 12px;
  width: 100%;
  height: 100%;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ball9 {
  z-index: 12;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background-color: white;
  position: absolute;
  right: 126px;
  top: 46%;
  box-shadow: inset 0px 0px 0px 5px #673ab7, 2px 2px 4px 0 rgba(0, 0, 0, 0.4);
}

.ball9::before {
  content: attr(data-num);
  font-size: 12px;
  width: 100%;
  height: 100%;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ball10 {
  z-index: 12;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background-color: white;
  position: absolute;
  right: 126px;
  top: 38%;
  box-shadow: inset 0px 0px 0px 5px #009688, 2px 2px 4px 0 rgba(0, 0, 0, 0.4);
}

.ball10::before {
  content: attr(data-num);
  font-size: 12px;
  width: 100%;
  height: 100%;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

              
            
!

JS

              
                gsap.to(".cue", { x: 100, ease: "back", delay: 4.4 });

let cuetl = gsap.timeline();

cuetl
  .to(".cue-ball", { x: 221, y: 10, delay: 4.5, duration: 0.3, rotation: 90 })
  .to(".cue-ball", { x: 230, y: 50, duration: 0.7 })
  .to(".cue-ball", { x: 220, y: 40, duration: 2, delay: 1 })
  .to(".cue-ball", { rotation: 360, duration: 3 });

let ball10 = gsap.timeline();

ball10
  .to(".ball10", { x: 100, y: -94, rotation: -360, delay: 4.8, duration: 0.8 })
  .to(".ball10", { scale: 0.6, opacity: 0, duration: 0.3 });

let ball9 = gsap.timeline();

ball9.to(".ball9", {
  x: 80,
  y: -70,
  rotation: -800,
  delay: 4.8,
  duration: 1.1
});

let ball8 = gsap.timeline();

ball8
  .to(".ball8", { x: 84, y: 20, rotation: 240, delay: 4.8, duration: 0.4 })
  .to(".ball8", { x: -78, y: 56, rotation: 600, duration: 1.6 });

let ball7 = gsap.timeline();

ball7
  .to(".ball7", { x: 88, y: 66, rotation: 240, delay: 4.8 })
  .to(".ball7", { scale: 0.6, opacity: 0, duration: 0.3 });

let ball6 = gsap.timeline();

ball6.to(".ball6", {
  x: 30,
  y: -40,
  rotation: -700,
  delay: 4.8,
  duration: 1.2
});

let ball5 = gsap.timeline();

ball5.to(".ball5", { x: 80, y: -20, rotation: -240, delay: 4.8, duration: 1 });

let ball4 = gsap.timeline();

ball4.to(".ball4", { x: 40, y: 60, rotation: 700, delay: 4.8, duration: 1.2 });

let ball3 = gsap.timeline();

ball3.to(".ball3", {
  x: 40,
  y: -10,
  rotation: -700,
  delay: 4.8,
  duration: 1.6
});

let ball2 = gsap.timeline();

ball2.to(".ball2", { x: 40, y: 5, rotation: -400, delay: 4.8, duration: 1.6 });

let ball1 = gsap.timeline();

ball1.to(".ball1", { x: 7, y: 15, rotation: 400, delay: 4.8, duration: 1.6 });

              
            
!
999px

Console