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="menu">
  <label for="b1">點我開啟/收折選單</label>
  <input type="checkbox" id="b1" class="btn">
  <div class="submenu">
    <div>Apple</div>
    <div>Banana</div>
    <div>OXXO</div>
    <div>Orange</div>
  </div>
  <label for="b2">點我開啟/收折選單</label>
  <input type="checkbox" id="b2" class="btn">
  <div class="submenu">
    <div>Apple</div>
    <div>Banana</div>
    <div>OXXO</div>
    <div>Orange</div>
  </div>
</div>
              
            
!

CSS

              
                .menu {
  box-sizing: border-box;
  width: 300px;
  margin: 20px;
  padding: 10px;
  font-size: 30px;
  border: 1px solid #000;
}
input {display: none;}    /* 隱藏 checkbox */
label {cursor: pointer;}  /* 滑鼠移動到上方時為手形指標 */
.submenu {
  overflow: hidden;       /* 超過範圍就隱藏 */
  width: 100%;            /* 寬度為父元素寬度 100% */
  max-height: 0;          /* 設定最大高度為 0,讓 transition 能有作用 */
  transition: .5s;        /* 轉場時間 0.5 秒 */
  padding-left: 10px;
  margin-bottom: 10px;
}
/* 勾選 checkbox 時,相鄰的下一個兄弟元素 .submenu 就顯示 */
input:checked + .submenu {
  max-height: 500px;      /* 設定最大高度為 500px,讓 transition 能有作用 */
  transition: 1s;         /* 因為最大高度可能比內容高度高得多,所以秒數設定較多 */
}
              
            
!

JS

              
                
              
            
!
999px

Console