Glassmorphism Popup
A modern popup window with glass-like transparency and blur effects.
HTML
<div class="container">
<div id="popup-container">
<button id="popup-btn" class="popup-btn">Glassmorphism</button>
</div>
<div id="popup" class="popup">
<div class="popup-content">
<p>Glassmorphism Popup</p>
<p>A modern popup window with glass-like transparency and blur effects.</p>
</div>
</div>
</div>
CSS
.container {
max-width: 800px;
margin: 0 auto;
text-align: center;
}
.container .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;
}
.container .popup-btn:hover {
opacity: 0.5;
}
.container .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%;
}
.container .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%);
}
}
.container .popup-content {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
padding: 30px;
border-radius: 20px;
text-align: center;
position: relative;
min-width: 300px;
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37), 0 0 0 1px rgba(255, 255, 255, 0.18);
overflow: hidden;
}
.container .popup-content::before {
content: '';
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
border-radius: 20px;
pointer-events: none;
}
.container .popup-content p:first-child {
font-size: 24px;
font-weight: bold;
margin-bottom: 15px;
color: #333;
text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}
.container .popup-content p:last-of-type {
font-size: 16px;
color: #555;
margin-bottom: 25px;
line-height: 1.6;
text-shadow: 0 1px 2px rgba(255,255,255,0.6);
}
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');
});
});