Pen Settings



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


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


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.


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.


<p>单击时使用 CSS 和 JavaScript 将菜单图标更改为“ - 或 + ”图标:</p>

<button class="accordion">第 1 节</button>
<div class="panel">

<button class="accordion">第 2 节</button>
<div class="panel">

<button class="accordion">第 3 节</button>
<div class="panel">


                /* 设置用于打开和关闭手风琴panel的按钮样式 */
.accordion {
  background-color: #eee;
  color: #444;
  cursor: pointer;
  padding: 18px;
  width: 100%;
  border: none;
  text-align: left;
  outline: none;
  font-size: 15px;
  transition: 0.4s;
.accordion:after {
  content: "\02795"; /* 加号(+)的Unicode字符 */
  font-size: 13px;
  color: #777;
  float: right;
  margin-left: 5px;
.active:after {
  content: "\2796"; /* “减号(-)的Unicode字符 */

/* 如果单击该按钮(使用JS添加.active类),并且当您将鼠标移到该按钮上时(悬停),请为其添加背景色 */
.accordion:hover {
  background-color: #ccc;
/* 设置手风琴panel的样式。注意:默认情况下隐藏 */
.panel {
  padding: 0 18px;
  background-color: white;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease-out;


                var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
  acc[i].addEventListener("click", function () {
    var panel = this.nextElementSibling;
    if ( { = null;
    } else { = panel.scrollHeight + "px";