<rss version="2.0">
  <channel>
    <title>Blog</title>
    <link>http://m96dev.com/</link>
    <description><![CDATA[This is the description of your blog]]></description>
    <item>
      <title>How to create animated border in CSS similar to Instagram reels circles?</title>
      <link>http://m96dev.com/blog/how-to-create-animated-border-in-css</link>
      <description><![CDATA[<p>Unfortunately, borders cannot be animated using border propery, but there is another way.</p>
<p>So what you essentialy have to do is actually simple.  You need to create two circles - outer and inner one. Outer circle will be slightly bigger than the inner and will have (animated) background, while inner circle will be responsible for the content.</p>
<p>Let's build Instagram reels circle and have border animation.</p>
<p>So this is the HTML structure:</p>
<pre><code>&lt;div class="circle-wrapper"&gt;
  &lt;div class="circle"&gt;
    &lt;img src="https://www.fcbarcelona.com/photo-resources/2026/01/09/1d7cf663-992b-40e4-8b29-9dff9103abeb/_MGA4181.jpg?width=1200&amp;height=750" /&gt;
  &lt;/div&gt;
&lt;/div&gt;
</code></pre>
<p>And this is the CSS:</p>
<pre><code>.circle-wrapper {
 position: relative;
    width: 128px;
    aspect-ratio: 1;
}

.circle-wrapper::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
     background: conic-gradient(
        red,
        purple,
        red
    );

    animation: bg-change 3s linear infinite;
}

.circle {
  position: absolute;
    inset: 4px;
    border-radius: 50%;
    overflow: hidden;
    background: white;
}
.circle img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}


@keyframes bg-change {
  to {
        transform: rotate(360deg);
    }
}
</code></pre>
<p>Since we want to rotate the background gradient, we need to ensure that the inner circle isn't affected by the animation and that's why we need to use ::before. If you need to do something that doesn't affect the inner circle, you can apply flex to the outer circle and then center the inner circle like that.</p>
<p>Anyway, the point is that the difference in size between the outer and the inner circle is your border.</p>
<p><img src="/media/yamal.jpg"></p>
]]></description>
      <pubDate>Fri, 10 Jul 2026 23:11:41 GMT</pubDate>
      <guid isPermaLink="true">http://m96dev.com/blog/how-to-create-animated-border-in-css</guid>
    </item>
  </channel>
</rss>