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

              
                <section class="faq ">
  <div class="inner">
    <h2 class="title">よくある質問</h2>
    <div class="faq__contents">
      <details class="faq__details js-details">
        <summary class="faq__summary js-summary">
          質問1<span class="arrow-icon"></span>
        </summary>
        <div class="faq__content js-content">
          <p class="faq__text">回答1テキストの部分です。回答1テキストの部分です。回答1テキストの部分です。回答1テキストの部分です。回答1テキストの部分です。回答1テキストの部分です。</p>
        </div>
      </details>
      <details class="faq__details js-details">
        <summary class="faq__summary js-summary">
          質問2<span class="arrow-icon"></span>
        </summary>
        <div class="faq__content js-content">
          <p class="faq__text"> 回答2テキストの部分です。回答2テキストの部分です。回答2テキストの部分です。回答2テキストの部分です。回答2テキストの部分です。回答2テキストの部分です。</p>
        </div>
      </details>
      <details class="faq__details js-details">
        <summary class="faq__summary js-summary">
          質問3<span class="arrow-icon"></span>
        </summary>
        <div class="faq__content js-content">
          <p class="faq__text">回答3テキストの部分です。回答3テキストの部分です。回答3テキストの部分です。回答3テキストの部分です。回答3テキストの部分です。回答3テキストの部分です。</p>
        </div>
      </details>
    </div>
  </div>
</section>
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  line-height: 1.6;
}

summary {
  display: block;
}

summary::-webkit-details-marker {
  display: none;
}
.faq {
  margin-top: 80px;
  margin-bottom: 80px;
}
.inner {
  max-width: 900px;
  padding: 0 4%;
  margin:0 auto;
}
.faq__contents {
  margin-top: 24px;
}
.faq__details {
  padding: 16px;
}
.faq__summary {
  cursor: pointer;
  position: relative;
  display: flex;
  justify-content: space-between;
  padding-left: 32px;
}

.faq__summary::before,
.faq__text::before {
  position: absolute;
  left: 0;
  height: 24px;
  width: 24px;
  border-radius: 50px;
  text-align: center;
  display: block;
}

.faq__summary::before {
  content: "Q";
  background-color: #2f3135;
  color: #ffffff;
  top: 0;
}

.faq__text::before {
  content: "A";
  background-color: #fd952e;
  color: #ffffff;
  top: 50%;
  transform: translateY(-50%);
}

/* 矢印アイコン */
.arrow-icon {
  display: inline-block;
  position: relative;
  transition: transform 0.4s ease;
  height: 16px;
  width: 16px;
  transform: rotate(135deg);
}

.arrow-icon::before {
  content: "";
  width: 10px;
  height: 10px;
  border-top: solid 2px #2f3135;
  border-right: solid 2px #2f3135;
  position: absolute;
  top: 50%;
  right: 50%;
}

/* アクティブな状態の矢印アイコン */
.arrow-icon.active {
  transform: rotate(315deg);
}
.faq__text {
  padding: 16px 32px;
  position: relative;
}

.faq__content {
  overflow: hidden;
}

              
            
!

JS

              
                document.querySelectorAll(".faq__details").forEach((details) => {
  const arrowIcon = details.querySelector(".arrow-icon");
  details.querySelector(".faq__summary").addEventListener("click", () => {
    arrowIcon.classList.toggle("active");
  });
});

              
            
!
999px

Console