Nature Popup
自然をテーマにしたオーガニックなポップアップウィンドウです。
HTML
<div class="container">
<button id="popup-btn">Nature</button>
</div>
<div id="popup" class="popup">
<div class="popup-content">
<p class="title">Nature Popup</p>
<p>自然をテーマにしたオーガニックなポップアップウィンドウです。</p>
</div>
</div>
CSS
.container {
text-align: center;
}
#popup-btn {
cursor: pointer;
border: none;
padding: 12px 24px;
border-radius: 16px;
color: #333;
background-color: #eee;
font-weight: 600;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
display: block;
margin: 0 auto;
width: 180px;
}
#popup-btn:hover {
opacity: 0.5;
}
.popup {
position: fixed;
bottom: -100%;
left: 50%;
transform: translateX(-50%);
z-index: 1001;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
max-width: 90%;
max-height: 90%;
}
.popup.active {
opacity: 1;
visibility: visible;
bottom: 20px;
transform: translateX(-50%);
animation: popupShowHide 3.4s ease forwards;
}
@keyframes popupShowHide {
0% {
opacity: 0;
transform: translateX(-50%) translateY(100%);
}
20% {
opacity: 1;
transform: translateX(-50%) translateY(0);
}
80% {
opacity: 1;
transform: translateX(-50%) translateY(0);
}
100% {
opacity: 0;
transform: translateX(-50%) translateY(100%);
}
}
.popup-content {
background: linear-gradient(135deg, #a8e6cf 0%, #dcedc1 50%, #ffd3b6 100%);
padding: 35px;
border-radius: 25px;
text-align: center;
position: relative;
min-width: 320px;
box-shadow:
0 15px 35px rgba(168, 230, 207, 0.3),
0 5px 15px rgba(0, 0, 0, 0.1);
border: 3px solid #4caf50;
animation: natureFloat 4s ease-in-out infinite;
overflow: hidden;
}
@keyframes natureFloat {
0%, 100% {
transform: translateY(0px) rotate(0deg);
}
25% {
transform: translateY(-8px) rotate(0.5deg);
}
50% {
transform: translateY(-4px) rotate(-0.5deg);
}
75% {
transform: translateY(-6px) rotate(0.3deg);
}
}
.popup-content p.title {
font-size: 26px;
font-weight: bold;
margin-bottom: 15px;
color: #2e7d32;
text-shadow: 0 2px 4px rgba(46, 125, 50, 0.2);
animation: natureText 3s ease-in-out infinite;
position: relative;
z-index: 1;
}
@keyframes natureText {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.02);
}
}
.popup-content p {
font-size: 16px;
color: #388e3c;
margin-bottom: 0;
line-height: 1.6;
font-weight: 500;
position: relative;
z-index: 1;
}
/* レスポンシブ対応 */
@media (max-width: 768px) {
.popup-content {
padding: 25px;
min-width: 280px;
}
.popup-content h2 {
font-size: 22px;
}
.popup-content p {
font-size: 14px;
}
#popup-btn {
padding: 12px 24px;
font-size: 14px;
}
}
@media (max-width: 480px) {
.popup-content {
padding: 20px;
min-width: 250px;
}
.popup-content h2 {
font-size: 20px;
}
.popup-content p {
font-size: 13px;
}
#popup-btn {
padding: 10px 20px;
font-size: 13px;
}
}
JavaScript
document.addEventListener('DOMContentLoaded', function() {
const popupBtn = document.getElementById('popup-btn');
const popup = document.getElementById('popup');
popupBtn.addEventListener('click', function() {
popup.classList.add('active');
});
popup.addEventListener('animationend', function() {
popup.classList.remove('active');
});
});