SVG Border Animation Card
SVGのrectストロークがカード外周を一周するボーダーアニメーション。
HTML
<div class="sbac-card">
<svg class="sbac-border" viewBox="0 0 280 180">
<rect class="sbac-rect" x="1" y="1" width="278" height="178" rx="15" fill="none" stroke="#6366f1" stroke-width="2"></rect>
</svg>
<div class="sbac-content">
<h3>Trace Border</h3>
<p>SVG animated outline</p>
</div>
</div>
CSS
.sbac-card {
position: relative;
width: 280px;
height: 180px;
background: #18181b;
border-radius: 16px;
}
.sbac-border {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}
.sbac-rect {
stroke-dasharray: 916;
stroke-dashoffset: 916;
animation: sbac-trace 3s ease-in-out infinite;
}
@keyframes sbac-trace {
0% { stroke-dashoffset: 916; }
50% { stroke-dashoffset: 0; }
100% { stroke-dashoffset: -916; }
}
.sbac-content {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
color: #e2e8f0;
}
.sbac-content h3 { margin: 0 0 4px; font-size: 18px; }
.sbac-content p { margin: 0; font-size: 12px; opacity: 0.6; }