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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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="example">
  <div class="example__ball"></div>
  <h1 class="example__title">Taiwan No.1!</h1>
  
  <button onclick="animateCircle()"> Build! </button>
</div>

              
            
!

CSS

              
                $main-color: #1a528b;
$bg-color: beige;
$shadow-color: rgba(0, 0, 0, .5);
* {
  box-sizing: border-box;
}

*:before, *:after {
  box-sizing: inherit;
}

body {
  height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

.example {
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  background-color: $bg-color;
}

.example__ball {
  height: 300px;
  width: 300px;
  position: relative;
  border-radius: 50%;
  background-color: $main-color;
  box-shadow: 5px 2px 60px $shadow-color;
}

.example__title {
  text-align: center;
  position: absolute;
  top: 45%;
  transform: translateY(-45%);
  color: lighten($main-color, 50);
  text-shadow: 3px 3px 3px $shadow-color;
}

.example button {
  position: fixed;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
}
              
            
!

JS

              
                function animateCircle() {
 // 使用 TimelineMax 物件
const tl = new TimelineMax();
// 利用 .set 設定擁有 class name .example__title 的元素
// 將其 scale 縮小成 0.2,透明度設為 0
tl
  .set(".example__title", {
    scale: 0.2,
    autoAlpha: 0
  })
  // 將擁有 class name .example__ball 的元素
  // scale 縮小成 0.2
  .set(".example__ball", {
    scale: 0.2
  })
  // tween 1: 在 1 秒內旋轉 360 度,並翻轉 180 度
  // 接著回復 scale 成原始大小,中間以 Elastic.easeIn 這個 ease function 來控制動畫速度
  .to(".example__ball", 1, {
    rotationX: 360,
    rotationY: 180,
    scale: 1,
    ease: Elastic.easeIn.config(2, 1)
  })
  // tween 2: 跟第一個補間動畫雷同,只是這次是控制文字,並在 0.5 內完成
  .to(".example__title", 0.5, {
    autoAlpha: 1,
    scale: 1,
    ease: Back.easeOut.config(4)
  });
}
              
            
!
999px

Console