svg {
width: 400px;
height: 100px;
}
#chain_st {
-webkit-animation: dash 1s infinite linear;
-moz-animation: dash 1s infinite linear;
-o-animation: dash 1s infinite linear;
animation: dash 1s infinite linear;
}
@keyframes dash {
to {
stroke-dashoffset: -5;
}
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: royalblue;
}
.block {
height: 400px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: center;
}
<div class="block">
<svg viewbox="0 0 100 40">
<path id="chain_st" stroke="black" fill="transparent" stroke-dasharray="2.6 2.45" d="M21.3 13.5 H20 C11.4 13.5 11.4 26.5 20 26.5 H80 C89 26.5 89 13.5 80.8 13.5z"></path>
</svg>
</div>
<path />您不太可能设置尺寸的尺寸,但您可以设置矩形<rect />。在这种情况下,您需要考虑到 svg 元素的笔画在其实际边框的两侧延伸。那些。如果笔画粗细为 2px,则 1px 将在元素内部,1px 将在元素外部。