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

              
                <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@500&display=swap" rel="stylesheet">

<details class="c-accordion">
  <summary class="c-accordion_ttl">Q. CSSのみでアコーディオンを作ることはできますか?</summary>
  <p class="c-accordion_txt">
    はい、detailsとsummary要素を使用していただくことで、HTMLのみでアコーディオンの挙動を作成することができます。<br>
    また、CSSを付与することで、デザインもお好きに変更していただくことができます。
    アコーディオンが開いているときのスタイルははsummary要素の[open]属性を使ってデザインしていきましょう。
  </p>
</details>

<details class="c-accordion red">
  <summary class="c-accordion_ttl">Q. CSSのみでアコーディオンを作ることはできますか?</summary>
  <p class="c-accordion_txt">
    はい、detailsとsummary要素を使用していただくことで、HTMLのみでアコーディオンの挙動を作成することができます。<br>
    また、CSSを付与することで、デザインもお好きに変更していただくことができます。
    アコーディオンが開いているときのスタイルははsummary要素の[open]属性を使ってデザインしていきましょう。
  </p>
</details>
              
            
!

CSS

              
                * {
  font-family: "Noto Sans JP", sans-serif;
}

:root {
  --main-bg-color: #4a90e2;
  --sub-bg-color: #d32b75;
}

.c-accordion {
  width: 100%;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  margin-top: 80px;
  border-radius: 8px;
  border-style: solid;
  border-width: 4px;
  border-color: var(--main-bg-color);
  margin-bottom: 32px;
  &_ttl {
    background-image: url("data:image/svg+xml,%3Csvg width='28' height='29' viewBox='0 0 28 29' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 28.4248C21.732 28.4248 28 22.1568 28 14.4248C28 6.69282 21.732 0.424805 14 0.424805C6.26801 0.424805 0 6.69282 0 14.4248C0 22.1568 6.26801 28.4248 14 28.4248Z' fill='%234A90E2'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M13.5629 9.44141C13.8797 9.44141 14.1452 9.70697 14.156 10.0346L14.4282 18.3384C14.4389 18.666 14.1908 18.9316 13.8739 18.9316C13.5571 18.9316 13.2915 18.666 13.2808 18.3384L13.0086 10.0346C12.9979 9.70697 13.246 9.44141 13.5629 9.44141Z' fill='white' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M9.12875 14.186C9.11801 13.8584 9.36616 13.5928 9.683 13.5928H17.7147C18.0315 13.5928 18.2971 13.8584 18.3078 14.186C18.3186 14.5136 18.0704 14.7791 17.7536 14.7791H9.72188C9.40504 14.7791 9.13948 14.5136 9.12875 14.186Z' fill='white' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");
    background-position: right 24px center;
    background-size: 28px;
    background-repeat: no-repeat;
    list-style: none;
    padding: 32px;
    cursor: pointer;
    font-size: 18px;
    color: var(--main-bg-color);
    font-weight: bold;
  }
  &[open] &_ttl {
    background-image: url("data:image/svg+xml,%3Csvg width='29' height='29' viewBox='0 0 29 29' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14.2339 28.4248C21.9659 28.4248 28.2339 22.1568 28.2339 14.4248C28.2339 6.69282 21.9659 0.424805 14.2339 0.424805C6.5019 0.424805 0.233887 6.69282 0.233887 14.4248C0.233887 22.1568 6.5019 28.4248 14.2339 28.4248Z' fill='%234A90E2'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M9.36264 14.186C9.35191 13.8584 9.60005 13.5928 9.9169 13.5928H17.9486C18.2654 13.5928 18.531 13.8584 18.5417 14.186C18.5524 14.5136 18.3043 14.7791 17.9874 14.7791H9.95578C9.63894 14.7791 9.37338 14.5136 9.36264 14.186Z' fill='white' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");
  }
  &_txt {
    padding: 32px;
    padding-top: 0;
    margin-top: 0;
    color: #222222;
  }

  // 色違いパターン
  &.red {
    border-color: var(--sub-bg-color);
    .c-accordion_ttl {
      color: var(--sub-bg-color);
      background-image: url("data:image/svg+xml,%3Csvg width='28' height='29' viewBox='0 0 28 29' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 28.4248C21.732 28.4248 28 22.1568 28 14.4248C28 6.69282 21.732 0.424805 14 0.424805C6.26801 0.424805 0 6.69282 0 14.4248C0 22.1568 6.26801 28.4248 14 28.4248Z' fill='%23d32b75'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M13.5629 9.44141C13.8797 9.44141 14.1452 9.70697 14.156 10.0346L14.4282 18.3384C14.4389 18.666 14.1908 18.9316 13.8739 18.9316C13.5571 18.9316 13.2915 18.666 13.2808 18.3384L13.0086 10.0346C12.9979 9.70697 13.246 9.44141 13.5629 9.44141Z' fill='white' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M9.12875 14.186C9.11801 13.8584 9.36616 13.5928 9.683 13.5928H17.7147C18.0315 13.5928 18.2971 13.8584 18.3078 14.186C18.3186 14.5136 18.0704 14.7791 17.7536 14.7791H9.72188C9.40504 14.7791 9.13948 14.5136 9.12875 14.186Z' fill='white' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");
    }
    &[open] .c-accordion_ttl {
      background-image: url("data:image/svg+xml,%3Csvg width='29' height='29' viewBox='0 0 29 29' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14.2339 28.4248C21.9659 28.4248 28.2339 22.1568 28.2339 14.4248C28.2339 6.69282 21.9659 0.424805 14.2339 0.424805C6.5019 0.424805 0.233887 6.69282 0.233887 14.4248C0.233887 22.1568 6.5019 28.4248 14.2339 28.4248Z' fill='%23d32b75'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M9.36264 14.186C9.35191 13.8584 9.60005 13.5928 9.9169 13.5928H17.9486C18.2654 13.5928 18.531 13.8584 18.5417 14.186C18.5524 14.5136 18.3043 14.7791 17.9874 14.7791H9.95578C9.63894 14.7791 9.37338 14.5136 9.36264 14.186Z' fill='white' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console