HTML
<div class="container">
<button class="modal-button">Tech Circuit Modal</button>
</div>
<div class="mask"></div>
<div class="modal">
<div class="modal-content">
<p>[Tech Circuit Modal]</p>
<p>A high-tech modal window with circuit board patterns and digital effects. Features animated circuit lines and glowing connection points for a cyberpunk aesthetic.</p>
<div class="close-btn-container">
<button class="close-btn">Close</button>
</div>
</div>
</div>
CSS
.container {
text-align: center;
}
.modal-button {
padding: 15px 30px;
background: #1a1a1a;
color: #00ff41;
border: 2px solid #00ff41;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-shadow: 0 0 10px #00ff41;
box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
position: relative;
overflow: hidden;
font-family: 'Courier New', monospace;
}
.modal-button::before {
content: '';
position: absolute;
top: 0; left: -100%;
width: 100%; height: 100%;
background: linear-gradient(90deg, transparent, rgba(0, 255, 65, 0.2), transparent);
transition: left 0.5s;
}
.modal-button:hover::before {
left: 100%;
}
.modal-button:hover {
background: #00ff41;
color: #1a1a1a;
text-shadow: none;
box-shadow: 0 0 30px rgba(0, 255, 65, 0.6);
transform: scale(1.05);
}
.mask {
position: fixed;
top: 0; left: 0; width: 100%; height: 100%;
background: rgba(0, 0, 0, 0.9);
z-index: 1000;
opacity: 0; visibility: hidden;
transition: all 0.3s ease;
}
.mask.appear {
opacity: 1; visibility: visible;
}
.modal {
position: fixed;
top: 50%; left: 50%;
transform: translate(-50%, -50%) scale(0.8);
background: #0a0a0a;
padding: 40px;
border-radius: 12px;
z-index: 1001;
opacity: 0; visibility: hidden;
transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
max-width: 500px; width: 90%;
border: 2px solid #00ff41;
box-shadow: 0 0 30px rgba(0, 255, 65, 0.4);
overflow: hidden;
}
.modal::before {
content: '';
position: absolute;
top: 0; left: 0; width: 100%; height: 100%;
background:
linear-gradient(90deg, transparent 0%, rgba(0, 255, 65, 0.1) 50%, transparent 100%),
linear-gradient(0deg, transparent 0%, rgba(0, 255, 65, 0.1) 50%, transparent 100%),
repeating-linear-gradient(90deg, transparent, transparent 20px, rgba(0, 255, 65, 0.05) 20px, rgba(0, 255, 65, 0.05) 22px),
repeating-linear-gradient(0deg, transparent, transparent 20px, rgba(0, 255, 65, 0.05) 20px, rgba(0, 255, 65, 0.05) 22px);
pointer-events: none;
}
.modal::after {
content: '';
position: absolute;
top: 10px; left: 10px; right: 10px; bottom: 10px;
border: 1px solid rgba(0, 255, 65, 0.3);
border-radius: 8px;
pointer-events: none;
}
.modal.appear {
opacity: 1; visibility: visible;
transform: translate(-50%, -50%) scale(1);
}
.modal p {
color: #00ff41;
line-height: 1.7;
margin-bottom: 30px;
font-size: 16px;
text-shadow: 0 0 8px #00ff41;
text-align: center;
position: relative;
z-index: 2;
font-family: 'Courier New', monospace;
}
.close-btn {
padding: 12px 24px;
background: transparent;
color: #00ff41;
border: 2px solid #00ff41;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-shadow: 0 0 8px #00ff41;
box-shadow: 0 0 15px rgba(0, 255, 65, 0.3);
display: block;
margin: 0 auto;
position: relative;
z-index: 2;
font-family: 'Courier New', monospace;
}
.close-btn:hover {
background: #00ff41;
color: #1a1a1a;
text-shadow: none;
box-shadow: 0 0 25px rgba(0, 255, 65, 0.6);
transform: scale(1.05);
}
.circuit-points {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
overflow: hidden;
border-radius: 12px;
}
.circuit-point {
position: absolute;
width: 6px;
height: 6px;
background: #00ff41;
border-radius: 50%;
box-shadow: 0 0 10px #00ff41;
animation: circuitPulse 2s ease-in-out infinite;
}
@keyframes circuitPulse {
0%, 100% {
opacity: 0.3;
transform: scale(1);
box-shadow: 0 0 10px #00ff41;
}
50% {
opacity: 1;
transform: scale(1.5);
box-shadow: 0 0 20px #00ff41, 0 0 30px #00ff41;
}
}
@media (max-width: 768px) {
.modal {
width: 95%;
padding: 20px;
}
.modal p {
font-size: 14px;
}
.modal-button {
font-size: 14px;
padding: 10px 20px;
}
}
JavaScript
document.addEventListener('DOMContentLoaded', function() {
const modalBtn = document.querySelector('.modal-button');
const mask = document.querySelector('.mask');
const modal = document.querySelector('.modal');
const closeBtn = modal.querySelector('.close-btn');
// モーダルを開く
modalBtn.addEventListener('click', () => {
mask.classList.add('appear');
modal.classList.add('appear');
createCircuitPoints();
});
// マスクをクリックして閉じる
mask.addEventListener('click', () => {
closeModal();
});
// 閉じるボタンをクリックして閉じる
closeBtn.addEventListener('click', () => {
closeModal();
});
// ESCキーでモーダルを閉じる
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeModal();
}
});
// モーダルを閉じる関数
function closeModal() {
mask.classList.remove('appear');
modal.classList.remove('appear');
clearCircuitPoints();
}
// 回路接続点作成関数
function createCircuitPoints() {
const circuitContainer = document.createElement('div');
circuitContainer.className = 'circuit-points';
// 接続点を配置
const positions = [
{ top: '10%', left: '10%' },
{ top: '10%', right: '10%' },
{ bottom: '10%', left: '10%' },
{ bottom: '10%', right: '10%' },
{ top: '50%', left: '5%' },
{ top: '50%', right: '5%' },
{ top: '25%', left: '20%' },
{ top: '25%', right: '20%' },
{ bottom: '25%', left: '20%' },
{ bottom: '25%', right: '20%' }
];
positions.forEach((pos, index) => {
const point = document.createElement('div');
point.className = 'circuit-point';
point.style.animationDelay = `${index * 0.2}s`;
Object.keys(pos).forEach(key => {
point.style[key] = pos[key];
});
circuitContainer.appendChild(point);
});
modal.appendChild(circuitContainer);
}
// 回路接続点クリア関数
function clearCircuitPoints() {
const circuitContainer = modal.querySelector('.circuit-points');
if (circuitContainer) {
circuitContainer.remove();
}
}
// ホバーエフェクト
modal.addEventListener('mouseenter', function() {
this.style.boxShadow = '0 0 40px rgba(0, 255, 65, 0.6)';
});
modal.addEventListener('mouseleave', function() {
this.style.boxShadow = '0 0 30px rgba(0, 255, 65, 0.4)';
});
});