Accordion / 021 — 吹き出した|Speech Bubble
デザイン見本
- Speech bubble design
- Light blue color scheme
- Friendly and approachable
チャットの吹き出しをイメージした親しみやすいデザイン。 丸みを帯びたフォルムと爽やかなブルーが、フレンドリーな印象を与えます。
実装コード
HTML
<div class="container">
<div class="btn-box">
<button data-default-text="Speech Bubble Accordion" data-open-text="Close">Speech Bubble Accordion</button>
</div>
<div class="more">
<ul>
<li>Speech bubble design</li>
<li>Light blue color scheme</li>
<li>Friendly and approachable</li>
</ul>
</div>
</div>
CSS
/* アニメーション定義 */
@keyframes acc21-fadeIn {
0% {
opacity: 0;
transform: translateY(-8px) scale(0.95)
}
100% {
opacity: 1;
transform: translateY(0) scale(1)
}
}
.container {
width: 100%;
margin-bottom: 0;
}
.container .btn-box button {
width: 100%;
padding: 14px 20px;
background: #f0f8ff;
border: 2px solid #87ceeb;
border-radius: 20px;
font-size: 14px;
font-weight: 500;
color: #4682b4;
cursor: pointer;
transition: all 0.3s;
text-align: left;
position: relative;
box-shadow: 0 2px 8px rgba(135, 206, 235, 0.3);
}
.container .btn-box button::before {
content: '';
position: absolute;
bottom: -8px;
left: 16px;
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid #87ceeb;
}
.container .btn-box button::after {
content: '▼';
position: absolute;
right: 16px;
top: 50%;
transform: translateY(-50%);
font-size: 11px;
color: #4682b4;
transition: transform 0.3s;
}
.container .btn-box button:hover {
background: #e6f3ff;
transform: translateY(-1px);
}
.container .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.5s ease;
background: #f0f8ff;
margin-top: 8px;
position: relative;
}
.container .more.appear {
max-height: 200px;
animation: acc21-fadeIn 0.4s ease;
border: 2px solid #87ceeb;
border-radius: 12px;
box-shadow: 0 2px 8px rgba(135, 206, 235, 0.3);
}
.container:has(.more.appear) .btn-box button::after {
transform: translateY(-50%) rotate(180deg);
}
.container .more ul {
list-style: none;
padding: 16px 20px;
margin: 0;
}
.container .more li {
padding: 8px 0 8px 12px;
color: #4682b4;
font-size: 13px;
border-bottom: 1px solid rgba(135, 206, 235, 0.3);
}
.container .more li:last-child {
border-bottom: none;
}
JS
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll('.container').forEach(container => {
const button = container.querySelector('.btn-box button');
const content = container.querySelector('.more');
if (button && content) {
button.addEventListener('click', function() {
content.classList.toggle('appear');
// ボタンテキストの切り替え
if (content.classList.contains('appear')) {
this.textContent = this.dataset.openText || 'Close';
} else {
this.textContent = this.dataset.defaultText;
}
});
}
});
});