body, div, div::after, div::before {
display: flex;
justify-content: center;
align-items: center;
}
body {
height: 100vh;
margin: 0;
overflow: hidden;
}
div {
position: relative;
width: 100px;
height: 100px;
background: pink;
}
div::after, div::before {
position: absolute;
width: 100%;
height: 100%;
}
div::after {
content: 'after';
right: -110%;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Ccircle cx='50' cy='50' r='40' style='stroke-dasharray: 255px;stroke-width:2px; stroke: red; fill: none;'%3E%3Canimate attributeType='CSS' attributeName='stroke-dashoffset' from='255px' to='-255px' dur='2s' repeatCount='indefinite' /%3E%3C/circle%3E%3C/svg%3E ");
}
div::before {
content: 'before';
left: -110%;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Crect width='100' height='100' style='stroke-dasharray: 410px;stroke-width:3px; stroke: red; fill: none;'%3E%3Canimate attributeType='CSS' attributeName='stroke-dashoffset' from='420px' to='-420px' dur='2s' repeatCount='indefinite' /%3E%3C/rect%3E%3C/svg%3E ");
}