Animated Colorful Dialog
This dialog features vibrant colors and smooth animations. The design changes colors dynamically and includes playful interactive elements.
HTML
<div id="dialog-container">
<button id="dialog-btn">Animated Colorful<br>Dialog</button>
</div>
<!-- Dialog Window -->
<div id="dialog" class="dialog">
<div class="dialog-content">
<div class="colorful-header">
<div class="colorful-icon">🎨</div>
<span>Animated Colorful Dialog</span>
</div>
<div class="colorful-body">
<p>This dialog features vibrant colors and smooth animations. The design changes colors dynamically and includes playful interactive elements.</p>
</div>
<div class="colorful-footer">
<button class="colorful-btn-secondary">Skip</button>
<button class="colorful-btn-primary">Continue</button>
</div>
</div>
</div>
CSS
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 20px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
/* ダイアログコンテナ */
#dialog-container {
text-align: center;
}
/* ダイアログボタン */
#dialog-btn {
background-color: #007bff;
color: white;
border: none;
padding: 12px 24px;
border-radius: 6px;
cursor: pointer;
font-size: 16px;
font-weight: 500;
transition: all 0.3s ease;
min-width: 200px;
min-height: 60px;
display: inline-block;
text-align: center;
line-height: 1.4;
vertical-align: middle;
}
#dialog-btn:hover {
background-color: #0056b3;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}
/* ダイアログオーバーレイ */
.dialog {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
animation: fadeIn 0.3s;
}
/* ダイアログコンテンツ */
.dialog-content {
width: 80%;
max-width: 500px;
margin-top: 8%;
margin-left: auto;
margin-right: auto;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 20px;
padding: 0;
box-shadow:
0 20px 40px rgba(102, 126, 234, 0.3),
0 0 0 1px rgba(255, 255, 255, 0.1);
animation: colorfulSlideIn 0.6s ease-out;
overflow: hidden;
position: relative;
}
.dialog-content::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(45deg,
rgba(255, 255, 255, 0.1) 0%,
rgba(255, 255, 255, 0.05) 50%,
rgba(255, 255, 255, 0.1) 100%);
animation: colorShift 4s ease-in-out infinite;
pointer-events: none;
}
/* カラフルヘッダー */
.colorful-header {
background: linear-gradient(135deg, #ff6b6b, #4ecdc4);
padding: 20px;
text-align: center;
position: relative;
overflow: hidden;
}
.colorful-header::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: linear-gradient(45deg,
transparent 30%,
rgba(255, 255, 255, 0.2) 50%,
transparent 70%);
animation: shimmer 3s infinite;
pointer-events: none;
}
.colorful-icon {
font-size: 2.5em;
margin-bottom: 10px;
animation: iconBounce 2s ease-in-out infinite;
display: block;
}
.colorful-header span {
color: white;
font-size: 1.5em;
font-weight: 700;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
position: relative;
z-index: 1;
}
/* カラフルボディ */
.colorful-body {
padding: 25px;
background: rgba(255, 255, 255, 0.95);
position: relative;
}
.colorful-body::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 3px;
background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #feca57);
animation: rainbowMove 3s linear infinite;
}
.colorful-body p {
color: #333;
font-size: 1.1em;
line-height: 1.6;
margin: 0;
text-align: center;
}
/* カラフルフッター */
.colorful-footer {
padding: 20px;
background: rgba(255, 255, 255, 0.1);
display: flex;
justify-content: center;
gap: 15px;
backdrop-filter: blur(10px);
}
/* ボタンスタイル */
.colorful-btn-secondary {
background: linear-gradient(135deg, #667eea, #764ba2);
color: white;
border: none;
padding: 12px 24px;
border-radius: 25px;
cursor: pointer;
font-size: 1em;
font-weight: 600;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.colorful-btn-secondary::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
transition: left 0.5s;
}
.colorful-btn-secondary:hover::before {
left: 100%;
}
.colorful-btn-secondary:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}
.colorful-btn-primary {
background: linear-gradient(135deg, #ff6b6b, #4ecdc4);
color: white;
border: none;
padding: 12px 24px;
border-radius: 25px;
cursor: pointer;
font-size: 1em;
font-weight: 600;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
animation: pulse 2s infinite;
}
.colorful-btn-primary::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
transition: left 0.5s;
}
.colorful-btn-primary:hover::before {
left: 100%;
}
.colorful-btn-primary:hover {
transform: translateY(-2px) scale(1.05);
box-shadow: 0 10px 25px rgba(255, 107, 107, 0.5);
}
/* ======================================== アニメーション ======================================== */
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes colorfulSlideIn {
0% {
transform: translateY(-100px) scale(0.8);
opacity: 0;
}
50% {
transform: translateY(-20px) scale(0.95);
opacity: 0.8;
}
100% {
transform: translateY(0) scale(1);
opacity: 1;
}
}
@keyframes colorShift {
0%, 100% {
background: linear-gradient(45deg,
rgba(255, 255, 255, 0.1) 0%,
rgba(255, 255, 255, 0.05) 50%,
rgba(255, 255, 255, 0.1) 100%);
}
25% {
background: linear-gradient(45deg,
rgba(255, 182, 193, 0.1) 0%,
rgba(255, 255, 255, 0.05) 50%,
rgba(255, 182, 193, 0.1) 100%);
}
50% {
background: linear-gradient(45deg,
rgba(173, 216, 230, 0.1) 0%,
rgba(255, 255, 255, 0.05) 50%,
rgba(173, 216, 230, 0.1) 100%);
}
75% {
background: linear-gradient(45deg,
rgba(144, 238, 144, 0.1) 0%,
rgba(255, 255, 255, 0.05) 50%,
rgba(144, 238, 144, 0.1) 100%);
}
}
@keyframes shimmer {
0% {
transform: translateX(-100%) translateY(-100%) rotate(45deg);
}
100% {
transform: translateX(100%) translateY(100%) rotate(45deg);
}
}
@keyframes iconBounce {
0%, 20%, 50%, 80%, 100% {
transform: translateY(0);
}
40% {
transform: translateY(-10px);
}
60% {
transform: translateY(-5px);
}
}
@keyframes rainbowMove {
0% {
background-position: 0% 50%;
}
100% {
background-position: 200% 50%;
}
}
@keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.7);
}
70% {
box-shadow: 0 0 0 10px rgba(255, 107, 107, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(255, 107, 107, 0);
}
}
/* ======================================== レスポンシブ対応 ======================================== */
@media (max-width: 768px) {
.dialog-content {
width: 90%;
margin: 15% auto;
padding: 15px;
}
.colorful-header span {
font-size: 16px;
}
.colorful-body p {
font-size: 14px;
}
}
JavaScript
document.addEventListener('DOMContentLoaded', function() {
// ダイアログボタンのイベントリスナーを設定
const dialogBtn = document.getElementById('dialog-btn');
const dialog = document.getElementById('dialog');
dialogBtn.addEventListener('click', function() {
dialog.style.display = 'block';
// スクロールを無効化
document.body.style.overflow = 'hidden';
});
// 閉じるボタンのイベントリスナーを設定
const closeButtons = document.querySelectorAll('.colorful-btn-secondary, .colorful-btn-primary');
closeButtons.forEach(button => {
button.addEventListener('click', function() {
dialog.style.display = 'none';
// スクロールを有効化
document.body.style.overflow = 'auto';
});
});
});