Modal / 21 テックサーキット|Tech Circuit
デザイン見本
黒(#0a0a0a)とネオングリーン(#00ff41)のコントラスト、光を放つような`box-shadow`や`text-shadow`、そして`repeating-linear-gradient`で作られた電子基板のようなグリッドラインが特徴的な、ハッカー・サイバーパンク風のデザインです。ボタンホバー時には光が走るエフェクトが付いています。
実装コード
HTML
<!-- モーダルを開くボタン -->
<button class="modal-button">Tech Circuit Modal</button>
<!-- モーダルの背景マスク -->
<div class="mask"></div>
<!-- モーダル本体 -->
<div class="modal">
<div class="modal-content">
<p>【Tech Circuit Modal】</p>
<p>回路基板パターンのハイテクなモーダルウィンドウです。</p>
<div class="close-btn-container">
<button class="close-btn">Close</button>
</div>
</div>
</div>
CSS
/* 開くボタンのスタイル */
.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;
}
/* ホバー時に白い光が走るエフェクト */
.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);
}
/* 回路の光る点 */
.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; }
}
/* 背景マスクのスタイル */
.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.appear {
opacity: 1;
visibility: visible;
transform: translate(-50%, -50%) scale(1);
}
/* 回路基板パターンの背景 */
.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 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;
}
/* 閉じるボタンのスタイル */
.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;
}
.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);
}
JS
(function () {
var btn = document.querySelector('.modal-button');
var mask = document.querySelector('.mask');
var modal = document.querySelector('.modal');
var closeBtns = document.querySelectorAll('.close-btn');
if (!btn || !mask || !modal) return;
function openModal() {
mask.classList.add('appear');
modal.classList.add('appear');
}
function closeModal() {
mask.classList.remove('appear');
modal.classList.remove('appear');
}
// ホバーエフェクト
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)';
});
// 回路ポイント生成
function buildCircuitPoints(modal) {
if (modal.querySelector('.circuit-points')) return; // 既に生成済みならスキップ
var wrap = document.createElement('div');
wrap.className = 'circuit-points';
var coords = [
{ 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%' }
];
for (var c = 0; c < coords.length; c++) {
var pt = document.createElement('div');
pt.className = 'circuit-point';
// アニメーション遅延をランダムに
pt.style.animationDelay = (c * 0.2) + 's';
var pos = coords[c];
var keys = Object.keys(pos);
for (var ki = 0; ki < keys.length; ki++) {
pt.style[keys[ki]] = pos[keys[ki]];
}
wrap.appendChild(pt);
}
modal.appendChild(wrap);
}
// 初期化時にポイント生成
buildCircuitPoints(modal);
btn.addEventListener('click', openModal);
mask.addEventListener('click', closeModal);
closeBtns.forEach(function(b) { b.addEventListener('click', closeModal); });
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape' && modal.classList.contains('appear')) {
closeModal();
}
});
})();