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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <div class="loading">
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
</div>
              
            
!

CSS

              
                body {
  margin: 0;
  height: 100vh; /*=100%*/
  display: flex; /*flex布局*/
  align-items: center; /*flex布局:垂直居中*/
  justify-content: center; /*flex布局:水平居中*/
  background-color: black;
}

.loading {
  width: 10em;
  height: 10em;
  display: grid; /*grid布局*/
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 0.5em; /*grid 每个item之间的间距*/
  transform: rotate(45deg); /*旋转45°*/
}

/**
* --name  是css中定义变量的方式
* 可以直接用  var(--name) 使用
*/
.loading span {
  background-color: var(--color); /*背景颜色*/
}

.loading span:nth-child(2n+2) {
  /*n=0: 2*/
  /*n=1: 4*/
  /*n=2: 6*/
  /*n=3: 8*/
  /*n=4: 10(不存在)*/
  --color: #f13f84;
}
.loading span:nth-child(4n+3) {
  /*n=0: 3*/
  /*n=1: 7*/
  /*n=2: 11(不存在)*/
  --color: #46b0ff;
}
.loading span:nth-child(4n+1) {
  /*n=0: 1*/
  /*n=1: 5*/
  /*n=2: 9*/
  /*n=3: 13(不存在)*/
  --color: #44bb44;
}
.loading span {
  background-color: var(--color);
  /**
  * 动画名字是blinking
  * 动画整个时间是2s
  * 每个元素的执行延时时间 var(--delay)
  * 动画的速度曲线 由慢到快 ease-in-out
  * 永久执行 infinite
  */
  animation: blinking 2s var(--delay) ease-in-out infinite;
  animation-fill-mode: backwards;
}

/**
* 每个元素执行动画延时时间变量
*/
.loading span:nth-child(7) {
  --delay: 0s;
}
.loading span:nth-child(4n+4) {
  --delay: 0.2s;
}
.loading span:nth-child(4n+1) {
  --delay: 0.4s;
}
.loading span:nth-child(4n+2) {
  --delay: 0.6s;
}
.loading span:nth-child(3) {
  --delay: 0.8s;
}

/**
* 动画效果
*/
@keyframes blinking {
  0%, 20% {
    transform: rotate(0deg) scale(0);
  }
  40%, 80% {
    /*
    * 旋转一圈rotate(1turn)[转、圈(Turns)。一个圆共1圈]
    * 缩放 scale 如果大于1就代表放大;如果小于1就代表缩小
    */
    transform: rotate(1turn) scale(1);
  }
  100% {
    transform: rotate(2turn) scale(0);
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console