I want the border animation to follow the border-radius of div. However, the animation doesn’t follow the border radius.
.container {
height: 150px;
width: 150px;
border: 1px solid black;
border-radius: 20px;
background: yellow;
border-image: conic-gradient(from var(--angle), var(--c2), var(--c1) 0.1turn, var(--c1) 0.15turn, var(--c2) 0.25turn) 30;
animation: borderRotate var(--d) linear infinite forwards;
}
@keyframes borderRotate {
100% {
--angle: 420deg;
}
}
@property --angle {
syntax: '<angle>';
initial-value: 90deg;
inherits: true;
}
:root {
--d: 2500ms;
--angle: 90deg;
--c1: red;
--c2: blue;
}
<div class="container"></div>
How do i achieve the animation with border radius ?
2
Answers
You can try this border animation.
Is this what you are trying to achieve? Using pseudo elements, you offset the
::before
element by 50% while also making it 200% of its original size. Then overlay an::after
pseudo element.