- Yellow sticky note appearance
- Natural paper texture
- Friendly and approachable
Accordion / 011 — 付箋風|Sticky Note Style
デザイン見本
黄色い付箋をモチーフにした親しみやすいデザイン。 コンテンツが表示される際のアニメーションや、上部のカラーバーなど、細部までこだわった作りになっています。
実装コード
HTML
<div class="container">
<div class="btn-box">
<button data-default-text="Sticky Note Style Accordion" data-open-text="Close">Sticky Note Style Accordion</button>
</div>
<div class="content">
<ul>
<li>Yellow sticky note appearance</li>
<li>Natural paper texture</li>
<li>Friendly and approachable</li>
</ul>
</div>
</div>
CSS
/* アニメーション定義 */
@keyframes acc11-stickyIn {
0% {
opacity: 0;
transform: translateY(-10px) scale(0.95)
}
100% {
opacity: 1;
transform: translateY(0) scale(1)
}
}
.container {
width: 100%;
margin: 4px;
position: relative;
}
.container .btn-box button {
width: 100%;
padding: 16px 20px;
background: #fff9c4;
border: 1px solid #fbc02d;
border-radius: 8px 8px 0 0;
font-size: 14px;
font-weight: 600;
color: #333;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
position: relative;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.container .btn-box button::after {
content: '▼';
position: absolute;
right: 16px;
top: 50%;
transform: translateY(-50%);
color: #fbc02d;
font-size: 13px;
transition: transform 0.3s ease;
}
.container .btn-box button:hover {
background: #fff8e1;
}
.container .content {
max-height: 0;
overflow: hidden;
transition: max-height 0.5s ease;
background: #fff;
border: 1px solid #ddd;
border-radius: 0 0 8px 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
position: relative;
margin-top: 0;
}
.container .content::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 4px;
background: linear-gradient(90deg, #fff9c4, #fbc02d, #fff9c4);
border-radius: 8px 8px 0 0;
}
.container .content.appear {
max-height: 200px;
margin-top: 8px;
animation: acc11-stickyIn 0.4s ease;
}
.container:has(.content.appear) .btn-box button::after {
transform: translateY(-50%) rotate(180deg);
}
.container .content ul {
list-style: none;
padding: 20px;
margin: 0;
}
.container .content li {
padding: 8px 0 8px 16px;
color: #333;
border-bottom: 1px solid #f0f0f0;
font-size: 13px;
position: relative;
}
.container .content li::before {
content: '•';
position: absolute;
left: 0;
color: #fbc02d;
font-weight: bold;
}
.container .content li:last-child {
border-bottom: none;
}
JS
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll('.container').forEach(container => {
const button = container.querySelector('.btn-box button');
// .more または .content を取得
const content = container.querySelector('.more, .content');
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;
}
});
}
});
});