Floating Action Popup
A dynamic popup window with floating animation and action-oriented design.
HTML
<div class="container">
<div id="popup-container">
<button id="popup-btn" class="popup-btn">Floating Action</button>
</div>
<div id="popup" class="popup">
<div class="popup-content">
<p>Floating Action Popup</p>
<p>A dynamic popup window with floating animation and action-oriented design.</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: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 30px;
border-radius: 25px;
text-align: center;
position: relative;
min-width: 300px;
box-shadow: 0 20px 40px rgba(102, 126, 234, 0.3);
border: 2px solid rgba(255,255,255,0.2);
animation: floatingAction 3s ease-in-out infinite;
}
@keyframes floatingAction {
0%, 100% { transform: translateY(0px); }
50% { transform: translateY(-8px); }
}
.container .popup-content::before {
content: '';
position: absolute;
top: -2px; left: -2px; right: -2px; bottom: -2px;
background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
border-radius: 27px;
z-index: -1;
animation: borderRotate 4s linear infinite;
}
@keyframes borderRotate {
0% { filter: hue-rotate(0deg); }
100% { filter: hue-rotate(360deg); }
}
.container .popup-content p:first-child {
font-size: 24px;
font-weight: bold;
margin-bottom: 15px;
color: white;
text-shadow: 0 2px 4px rgba(0,0,0,0.3);
animation: textPulse 2s ease-in-out infinite;
}
@keyframes textPulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.05); }
}
.container .popup-content p:last-of-type {
font-size: 16px;
color: rgba(255,255,255,0.9);
margin-bottom: 25px;
line-height: 1.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');
});
});