Accordion / 018 — ネイチャー|Nature
デザイン見本
- Natural wood grain texture
- Organic color palette
- Warm and charming design
自然を感じさせる温かみのあるデザイン。 木目調のカラーパレットと葉をイメージしたアクセントラインが、オーガニックな雰囲気を演出します。 他デザイン同様、排他制御機能付きです。
実装コード
HTML
<div class="container">
<div class="btn-box">
<button data-default-text="Nature Accordion" data-open-text="Close">Nature Accordion</button>
</div>
<div class="more">
<ul>
<li>Natural wood grain texture</li>
<li>Organic color palette</li>
<li>Warm and charming design</li>
</ul>
</div>
</div>
CSS
/* アニメーション定義 */
@keyframes acc18-natureFadeIn {
0% {
opacity: 0;
transform: translateY(-10px) scale(0.98)
}
100% {
opacity: 1;
transform: translateY(0) scale(1)
}
}
@keyframes acc18-leafShift {
0% {
background-position: 0% 50%
}
50% {
background-position: 100% 50%
}
100% {
background-position: 0% 50%
}
}
.container {
margin: 4px 0;
position: relative;
width: 100%;
}
.container .btn-box button {
width: 100%;
padding: 16px 20px;
background: linear-gradient(135deg, #8B4513, #A0522D, #CD853F);
border: none;
border-radius: 12px;
font-size: 14px;
font-weight: 600;
color: #fff;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
overflow: hidden;
}
.container .btn-box button:hover {
background: linear-gradient(135deg, #A0522D, #CD853F, #DEB887);
transform: translateY(-2px);
}
.container .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.5s ease;
background: linear-gradient(135deg, #F5DEB3, #F4A460, #DEB887);
border-radius: 0 0 12px 12px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
z-index: 1;
position: relative;
}
.container .more::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 3px;
background: linear-gradient(90deg, #228B22, #32CD32, #90EE90, #228B22);
background-size: 200% 100%;
animation: acc18-leafShift 3s ease infinite;
}
.container .more.appear {
max-height: 200px;
margin-top: -5px;
animation: acc18-natureFadeIn 0.4s ease;
}
.container .more ul {
list-style: none;
padding: 18px 22px;
margin: 0;
}
.container .more li {
padding: 10px 0;
color: #654321;
font-weight: 500;
border-bottom: 1px solid rgba(101, 67, 33, 0.2);
font-size: 13px;
}
.container .more li:last-child {
border-bottom: none;
}
JS
document.addEventListener("DOMContentLoaded", () => {
const containers = document.querySelectorAll('.container');
containers.forEach(container => {
const button = container.querySelector('.btn-box button');
const content = container.querySelector('.more');
if (button && content) {
button.addEventListener('click', function() {
const isOpen = content.classList.contains('appear');
// 他のアコーディオンを閉じる
containers.forEach(c => {
const cContent = c.querySelector('.more');
const cButton = c.querySelector('.btn-box button');
if(cContent) cContent.classList.remove('appear');
if(cButton) cButton.textContent = cButton.dataset.defaultText;
});
// クリックされたものだけ開く
if (!isOpen) {
content.classList.add('appear');
this.textContent = this.dataset.openText || 'Close';
}
});
}
});
});