Card Style Popup
A popup window with a card-like appearance design.
HTML
<div class="container">
<button id="popup-btn">Card Style</button>
<div id="popup" class="popup">
<div class="popup-content">
<p>Card Style Popup</p>
<p>A popup window with a card-like appearance design.</p>
</div>
</div>
</div>
CSS
body {
font-family: Arial, sans-serif;
padding: 20px;
background: #f5f5f5;
}
.container {
max-width: 800px;
margin: 0 auto;
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(145deg, #ffffff 0%, #f8f9fa 100%);
padding: 30px;
border-radius: 20px;
text-align: center;
position: relative;
min-width: 300px;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
border: 1px solid #e9ecef;
transform: rotate(-1deg);
}
.popup-content::before {
content: '';
position: absolute;
top: -2px;
left: -2px;
right: -2px;
bottom: -2px;
background: linear-gradient(45deg, #28a745, #20c997);
border-radius: 22px;
z-index: -1;
opacity: 0.1;
}
.popup-content p:first-child {
font-size: 24px;
font-weight: bold;
margin-bottom: 15px;
color: #28a745;
text-shadow: 0 1px 2px rgba(40, 167, 69, 0.1);
}
.popup-content p:last-of-type {
font-size: 16px;
color: #666;
margin-bottom: 25px;
line-height: 1.6;
}
/* レスポンシブ対応 */
@media (max-width: 768px) {
.popup-content {
padding: 20px;
min-width: 280px;
}
.popup-content p:first-child {
font-size: 20px;
}
.popup-content p:last-of-type {
font-size: 14px;
}
#popup-btn {
padding: 10px 20px;
font-size: 14px;
}
}
@media (max-width: 480px) {
.popup-content {
padding: 15px;
min-width: 250px;
}
.popup-content p:first-child {
font-size: 18px;
}
.popup-content p:last-of-type {
font-size: 13px;
}
#popup-btn {
padding: 8px 16px;
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');
});
});