Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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="sky">
  <div class="star"></div>
</div>
              
            
!

CSS

              
                div {position: relative;}
.sky {
  margin: 20px;
  width: 400px;
  height: 400px;
  background: linear-gradient(#336 0, #000 100%); /* 外層加上藍到黑的背景 */
}
.star {
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
      35deg,
      #0000 1px, #0000 2px,
      #000 2px, #000 51px,
      #0000 51px, #0000 52px,
      #000 52px, #000 80px),
      repeating-linear-gradient(
      -35deg,
      #fff 1px, #fff 2px,
      #000 2px, #000 51px,
      #fff8 51px, #fff8 52px,
      #000 52px, #000 80px);
  mix-blend-mode: screen;   /* 混合模式 */
}
/* 虛擬元素 */
.star::before, .star:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  mix-blend-mode: screen;
}
/* 虛擬元素製作第二層星空,注意角度和間距有所不同 */
.star::before {
  background: repeating-linear-gradient(
      80deg,
      #0000 1px, #0000 2px,
      #000 2px, #000 51px),
      repeating-linear-gradient(
      0deg,
      #fffa 1px, #fffa 2px,
      #000 2px, #000 51px);
}
/* 虛擬元素製作流星,注意漸層色的位置 */
.star::after {
  background: repeating-linear-gradient(
      35deg,
      #0000 1px, #0000 2px,
      #000 100px, #000 500px),
      repeating-linear-gradient(
      -35deg,
      #fff 1px, #fff 2px,
      #000 2px, #000 400px);
  background-size: 200% 200%;    /* 調整尺寸 */
  background-position: 200% 20%; /* 調整位置 */
}
              
            
!

JS

              
                
              
            
!
999px

Console