アコーディオン:吹き出し風|Accordion: Speech Bubble
- Speech bubble design
- Rounded corners with tail
- Light blue color scheme
- Chat message appearance
- 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>Rounded corners with tail</li>
<li>Light blue color scheme</li>
<li>Chat message appearance</li>
<li>Friendly and approachable</li>
</ul>
</div>
</div>
CSS
@keyframes speechBubbleFadeIn {
0% {
opacity: 0;
transform: translateY(-8px) scale(0.95);
}
100% {
opacity: 1;
transform: translateY(0) scale(1);
}
}
.container {
margin: 25px 0;
position: relative;
}
.container .btn-box button {
width: 100%;
padding: 18px 25px;
background: #f0f8ff;
border: 2px solid #87ceeb;
border-radius: 20px 20px 20px 20px;
font-size: 16px;
font-weight: 500;
color: #4682b4;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
position: relative;
font-family: 'Arial', sans-serif;
box-shadow: 0 2px 8px rgba(135, 206, 235, 0.3);
}
.container .btn-box button::before {
content: '';
position: absolute;
bottom: -8px;
left: 20px;
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: 20px;
top: 50%;
transform: translateY(-50%);
font-size: 12px;
color: #4682b4;
transition: transform 0.3s ease;
}
.container .btn-box button:hover {
background: #e6f3ff;
border-color: #5f9ea0;
color: #2e8b57;
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(135, 206, 235, 0.4);
}
.container .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.5s ease;
background: #f0f8ff;
border: none;
box-shadow: none;
margin-top: 8px;
position: relative;
}
.container .more::before {
content: '';
position: absolute;
top: -8px;
left: 20px;
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid #87ceeb;
}
.container .more.appear {
max-height: 500px;
animation: speechBubbleFadeIn 0.4s ease;
border: 2px solid #87ceeb;
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: 25px 25px 20px;
margin: 0;
}
.container .more li {
padding: 10px 0;
color: #4682b4;
font-size: 15px;
line-height: 1.6;
border-bottom: 1px solid rgba(135, 206, 235, 0.3);
position: relative;
padding-left: 15px;
}
.container .more li:hover {
color: #2e8b57;
padding-left: 20px;
}
.container .more li:last-child {
border-bottom: none;
}
/* レスポンシブ対応 */
@media (max-width: 768px) {
.container .btn-box button {
font-size: 14px;
padding: 15px 20px;
border-radius: 15px 15px 15px 5px;
}
.container .more {
border-radius: 15px 15px 15px 5px;
}
.container .more ul {
padding: 20px 20px 15px;
}
.container .more.appear {
max-height: 400px;
}
}
JavaScript
// Add event listeners to all accordion buttons
document.addEventListener('DOMContentLoaded', function() {
const accordionButtons = document.querySelectorAll('.btn-box button');
accordionButtons.forEach(button => {
button.addEventListener('click', function() {
const container = this.closest('.container');
const more = container.querySelector('.more');
const isOpen = more.classList.contains('appear');
more.classList.toggle('appear');
// Change button text
if (this.dataset.defaultText) {
if (isOpen) {
this.textContent = this.dataset.defaultText;
} else {
this.textContent = this.dataset.openText || 'Close';
}
}
});
});
});