メモ帳から飛び出す付箋アコーディオン

A. 付箋メモのような見た目で、ちょっとした情報を書き留めるような気軽な雰囲気です。

A. ブログ、学習系、ライフハック紹介など、ラフな雰囲気のコンテンツと相性抜群です。

HTML
<div class="accordion-fusen">
  <div class="accordion-item">
    <button class="accordion-question">Q. このアコーディオンはどんなイメージ?</button>
    <div class="accordion-answer">
      <p>A. 付箋メモのような見た目で、ちょっとした情報を書き留めるような気軽な雰囲気です。</p>
    </div>
  </div>

  <div class="accordion-item">
    <button class="accordion-question">Q. どんなサイトに合う?</button>
    <div class="accordion-answer">
      <p>A. ブログ、学習系、ライフハック紹介など、ラフな雰囲気のコンテンツと相性抜群です。</p>
    </div>
  </div>
</div>
CSS
.accordion-fusen {
  max-width: 600px;
  margin: 60px auto;
  font-family: 'Kosugi Maru', sans-serif;
}

.accordion-item {
  margin-bottom: 20px;
}

.accordion-question {
  background: #fffbc1;
  border: none;
  width: 100%;
  text-align: left;
  padding: 16px 20px;
  font-size: 16px;
  font-weight: bold;
  color: #4a4a4a;
  border-left: 8px solid #f2c94c;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  position: relative;
  transition: background 0.3s ease;
}

.accordion-question:hover {
  background: #fff79d;
}

.accordion-question::after {
  content: '+';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: #a67c00;
  font-weight: bold;
}

.accordion-question.active::after {
  content: '-';
}

.accordion-answer {
  display: none;
  padding: 14px 20px;
  background: #fffef2;
  border-left: 8px solid #f2c94c;
  font-size: 15px;
  line-height: 1.7;
  color: #555;
  box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.05);
}
JavaScript
document.addEventListener('DOMContentLoaded', function () {
  const questions = document.querySelectorAll('.accordion-fusen .accordion-question');

  questions.forEach((btn) => {
    btn.addEventListener('click', () => {
      btn.classList.toggle('active');
      const answer = btn.nextElementSibling;
      answer.style.display = answer.style.display === 'block' ? 'none' : 'block';
    });
  });
});

🌟 有料会員限定素材を配布中!

ここでしか手に入らない特別デザイン素材を今すぐチェック!

有料会員ページを見る
目次