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 id="grid">
  <div id="title">Game Title</div>
  <div id="score">Score</div>
  <div id="stats">Stats</div>
  <div id="board">Board</div>
  <div id="controls">Controls</div>
</div>
              
            
!

CSS

              
                #grid {
  display: grid;
  background-color: orange;

 /* 分为两列: 
  * 第一列尺寸由内容大小控制
  * 第二列使用剩余空间,但大小从不会小于游戏主机板和控制区域最小宽度
  * 游戏主面板和游戏控制区域占在第二列
  */
 grid-definition-columns: auto minmax(min-content, 1fr);

 /* 三行: 
  * 第一行和最后一行的大小根据内容决定
  * 中间一行可以使用剩余空间,但从来不会小于游戏主面板的最小高度
  */
  grid-definition-rows: auto minmax(min-content, 1fr) auto
}

/*游戏的每一部分都是通过网格线来定义的,每个部分都在其占的行中,如果哪个部分占有的行数多于一行,需要使用跨行来决定*/
#title{ 
  grid-column: 1; 
  grid-row: 1 ;
  background-color: red;
}
#score{ 
  grid-column: 1; 
  grid-row: 3;
  background-color:green;
}
#stats{ 
  grid-column: 1; 
  grid-row: 2; 
  justify-self: start ;
  background-color:#e9f;
}
#board{ 
  grid-column: 2; 
  grid-row: 1 / span 2; 
  background-color: #ccc;
}
#controls { 
  grid-column: 2; 
  grid-row: 3; 
  align-self: center;
  background-color: yellow;
}

              
            
!

JS

              
                
              
            
!
999px

Console