-
Electric Card border Animation
HTML
CSS
JavaScript
VOLTAGE
DANGER: HIGH FREQUENCY
SYSTEM ACTIVE
:root { --bg-color: #020617; --card-bg: #0f172a; --electric-blue: #00f2ff; --spark-speed: 2s; } body { background-color: var(--bg-color); display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } /* The Main Container */ .electric-card { position: relative; width: 270px; height: 380px; background: var(--card-bg); border-radius: 20px; display: flex; justify-content: center; align-items: center; overflow: hidden; transition: transform 0.3s ease; cursor: pointer; } /* The Animated Electric Current (Pseudo-element) */ .electric-card::before { content: ''; position: absolute; width: 150%; height: 150%; /* Multiple color stops create "thin bolts" instead of a solid block */ background: conic-gradient( from 0deg, transparent 0%, var(--electric-blue) 2%, transparent 5%, transparent 40%, var(--electric-blue) 42%, transparent 45%, transparent 100% ); animation: rotate var(--spark-speed) linear infinite, flicker 0.1s infinite; filter: blur(5px) contrast(1.5); } /* Second layer for extra "plasma" glow */ .electric-card::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(0, 242, 255, 0.15) 0%, transparent 60%); opacity: 0; transition: opacity 0.3s; } .electric-card:hover::after { opacity: 1; } /* The Inner Card Body */ .card-inner { position: absolute; inset: 4px; /* The thickness of the electric border */ background: var(--card-bg); border-radius: 18px; z-index: 2; display: flex; flex-direction: column; justify-content: center; align-items: center; color: white; text-align: center; padding: 20px; border: 1px solid rgba(255, 255, 255, 0.05); } h2 { margin: 0; letter-spacing: 4px; color: var(--electric-blue); text-shadow: 0 0 10px rgba(0, 242, 255, 0.5); } p { font-size: 0.9rem; opacity: 0.7; margin-top: 10px; } /* Animations */ @keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes flicker { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } 75% { opacity: 0.9; } 85% { opacity: 0.4; } /* Mimics a spark "pop" */ } /* Hover interaction via JS */ .electric-card:hover { --spark-speed: 0.6s; /* Current flows faster on hover */ box-shadow: 0 0 30px rgba(0, 242, 255, 0.2); }
Live Preview