project demo
html code
Animated Zigzag Border
Border Animation
The Dark CSS zigzag border is rotating around the box using CSS animation.
css code
@import url('https://fonts.googleapis.com/css2?family=Anton&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
body {
background: #0f172a;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
font-family: "Poppins", sans-serif;
}
.card {
position: relative;
width: 320px;
overflow: hidden;
z-index: 1;
padding: 30px;
background: #1e293b;
color: #fff;
border-radius: 12px;
text-align: center;
}
.card::before {
content: "";
position: absolute;
inset: 0;
padding: 6px;
background:
repeating-linear-gradient(45deg, #eaea33 0 6px, transparent 6px 12px),
repeating-linear-gradient(-45deg, #eaea33 0 6px, transparent 6px 12px);
mask:
linear-gradient(#000 0 0) content-box,
linear-gradient(#000 0 0);
mask-composite: exclude;
border-radius: 12px;
z-index: -1;
background-size: 30px 30px;
animation: moveZigzag 3s linear infinite;
}
.card h2 {
font-weight: 600;
margin-bottom: 10px;
font-size: 1.5rem;
color: #eaea33;
letter-spacing: 1.3px;
}
.card p {
font-size: 0.95rem;
color: #e2e8f0;
}
@keyframes moveZigzag {
0% {
background-position: 0 0, 0 0;
}
100% {
background-position: 60px 60px, -60px -60px;
}
}