Creating a circular border with a gradient color scheme using HTML and CSS

I created a unique animation with circle borders using HTML and CSS:

<div class="spin"></div>
@keyframes spinner {
0% {
    transform: translate3d(-50%, -50%, 0) rotate(360deg);
}

100% {
    transform: translate3d(-50%, -50%, 0) rotate(0deg);
}
}    
.spin::before {
    animation: 2s linear infinite spinner;
    animation-play-state: inherit;
    border: solid 6px blue;
    border-bottom-color: transparent;
    border-radius: 100%;
    content: "";
    height: 70px;
    width: 70px;
    position: absolute;
    top: 90%;
    left: 90%;
    transform: translate3d(-50%, -50%, 1);
    will-change: transform;
    margin-top: -70px;
}

Here is the visual representation of the animation:

1. How can I apply gradient colors to the circle border?

2. Is there a way to customize the border radius of the circle?

Example like this:

![][2]

To achieve my goal, I utilized an SVG file :

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Creator: CorelDRAW -->
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="25.8524mm" height="25.8524mm" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
viewBox="0 0 158.05 158.05"
 xmlns:xlink="http://www.w3.org/1999/xlink"
 xmlns:xodm="http://www.corel.com/coreldraw/odm/2003">
 <defs>
  <style type="text/css">
   <![CDATA[
    .fil0 {fill:#2C80EB;fill-rule:nonzero}
   ]]>
  </style>
   <mask id="id0">
  <linearGradient id="id1" gradientUnits="userSpaceOnUse" x1="79.79" y1="128.31" x2="146.43" y2="131.43">
   <stop offset="0" style="stop-opacity:1; stop-color:white"/>
   <stop offset="0.34902" style="stop-opacity:0.501961; stop-color:white"/>
   <stop offset="1" style="stop-opacity:0; stop-color:white"/>
  </linearGradient>
    <rect style="fill:url(#id1)" width="158.05" height="158.05"/>
   </mask>
 </defs>
 <g id="Layer_x0020_1">
  <metadata id="CorelCorpID_0Corel-Layer"/>
  <path class="fil0" style="mask:url(#id0)" d="M79.02 0c3.57,0 6.47,2.9 6.47,6.47 0,3.57 -2.9,6.47 -6.47,6.47 -18.25,0 -34.77,7.4 -46.73,19.35 -11.96,11.96 -19.35,28.48 -19.35,46.73 0,18.25 7.4,34.77 19.35,46.73 11.96,11.96 28.48,19.35 46.73,19.35 18.25,0 34.77,-7.4 46.73,-19.35 11.96,-11.96 19.35,-28.48 19.35,-46.73 0,-3.57 2.9,-6.47 6.47,-6.47 3.57,0 6.47,2.9 6.47,6.47 0,21.82 -8.85,41.58 -23.15,55.88 -14.3,14.3 -34.06,23.15 -55.88,23.15 -21.82,0 -41.58,-8.85 -55.88,-23.15 -14.3,-14.3 -23.15,-34.06 -23.15,-55.88 0,-21.82 8.85,-41.58 23.15,-55.88 14.3,-14.3 34.06,-23.15 55.88,-23.15z"/>
 </g>
</svg>

https://i.sstatic.net/Dwa9w.png

Answer №1

When utilizing a background-image for a gradient effect, the border-radius feature is disregarded.

Therefore, this code snippet uses both a radial and conic gradient to produce a circular shape transitioning in color from blue to transparent.

<div class="spin"></div>
<style>
  @keyframes spinner {
    0% {
      transform: translate3d(-50%, -50%, 0) rotate(360deg);
    }
    100% {
      transform: translate3d(-50%, -50%, 0) rotate(0deg);
    }
  }
  
  .spin::before {
    animation: 2s linear infinite spinner;
    animation-play-state: inherit;
    background-image: radial-gradient(white 0 60%, transparent 40% 100%), conic-gradient(blue 0deg, transparent 360deg);
    border-radius: 100%;
    content: "";
    height: 70px;
    width: 70px;
    position: absolute;
    top: 90%;
    left: 90%;
    transform: translate3d(-50%, -50%, 1);
    will-change: transform;
    margin-top: -70px;
  }
</style>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Automatically open Bootstrap dropdown upon loading the page

Displayed below is my dropdown menu styled using bootstrap: <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#" id="posuvnik">15min <strong class="caret"></strong></a> <ul class="dropd ...

Issue with mouse hover not triggering overlay effect between two div elements

I am trying to display articles in a 2x3 matrix with article details like image, title, author, and description wrapped inside a div. I want this entire div to be overlapped by another div of the same dimensions containing a single image. Below is a snipp ...

Stop the form from refreshing upon submission using an Ajax call in AngularJS

Currently, I am in the process of developing a search form that requires two inputs: Job title and Location. These keywords are used to gather data from various websites. However, upon submitting the form, the page refreshes itself. To prevent this, I have ...

Customize the appearance of a React tab to eliminate the border on the bottom

When it comes to styling material tabs, I've managed to customize them by creating a theme and overriding the defaults like this: MuiTab: { styleOverrides: { root: { textTransform: 'capitalize', // Set textTransform to capitalize ...

In Bootstrap 3, you can toggle individual collapsible items without affecting others by only closing the specific

I am facing an issue with my Bootstrap collapsible elements. I came across an answer that includes the necessary javascript to close only the collapsible items in my table, while leaving other collapsible items on the page (in the menu) unaffected. These i ...

What is the best way to ensure that the Bootstrap navbar remains collapsed at all times, regardless of the size of the

Is there a way to keep my Bootstrap navbar constantly collapsed regardless of the screen size? I'm currently using Bootstrap, and I've noticed that when the screen is larger, the navbar expands automatically. What can I do to ensure that the navb ...

HTML/CSS - Enhances user experience by zooming in on select tag when tapped on mobile devices

I am experiencing an issue with a select menu on mobile devices. Whenever I tap on the menu, it seems to zoom in slightly. Is there a particular -webkit property causing this behavior? How can I prevent the screen from zooming when I tap on the select me ...

Deactivate a chosen item following selection

Is there a way to deactivate a selectable element after it has been clicked in the scenario below? Additionally, I would like to modify its CSS style. $(function(){ $("#selectable").selectable({ stop: function() { var result = $( "#select-re ...

Tips for ensuring the counter displays numbers incrementally instead of all at once

Is it possible to make the counters count sequentially (from left to right) instead of all at the same time? Here is the code for my counter: (function($) { $.fn.countTo = function(options) { options = options || {}; return $(this).each(funct ...

When working with Vue.js, toggling the 'readonly' attribute of a textarea between true and false may not be effective

My goal is to accomplish the following: Allow the textarea to be edited when double-clicked; Prevent the textarea from being edited when it loses focus; However, regardless of toggling the 'readonly' attribute, I am currently unable to achieve ...

Uploading files along with additional data fields

I am facing a dilemma with my HTML form that has enctype="multipart/form-data" attribute. I have a DTO class with all the necessary setters and getters. Since I am submitting the form as multipart, I cannot use getParameter() method directly. In my servlet ...

Tips for Implementing Multiple CSS Toggle Switches on a Single Page Using JavaScript or jQuery

Fiddle I am currently working on developing a toggle switch feature that can drain the color from an image when toggled. While following a tutorial to create this switch using CSS, I realized that it requires creating a new class name for each switch used ...

horizontal Bootstrap Image Gallery

I'm having an issue with Bootstrap Thumbnails. Currently, my thumbnails are stacked vertically like this: img01. However, I want them to be in a horizontal layout. What should I do? This is my code: HTML: <div class="hrs" align="center"> ...

The shadow effects and color overlays do not seem to be functioning properly in Mozilla Firefox

I have designed a popup registration form using the Bootstrap modal class. To ensure form validation, I have integrated some jQuery validation engine functionality. Additionally, I customized the appearance by adding a box shadow, adjusting the background ...

Eliminate any spaces surrounding the text within the div tag

Is it possible to eliminate extra space at the end of text using CSS (or possibly JS)? I've experimented with various display properties, but none seem to be effective. I need to dynamically insert a blink-div at the conclusion of a multi-line sentenc ...

Angular HTML layout designed for seamless interaction

<div class ="row"> <div class ="col-md-6"> Xyz </div> <div class ="col-md-6"> Abc </div> </div> Using the code above, I can easily create a layout with two columns. Th ...

Retrieve Element By Class Name in JavaScript

How can I modify the border color at the bottom of the .arrow_box:after? Javascript Solution document.getElementsByClassName("arrow_box:after")[0].style.borderBottomColor = "blue"; Despite trying this solution, it seems to be ineffective! For a closer ...

What is the best way to enable an image to be moved on top of another image?

Is there a way to allow users to drag around an image that is positioned on top of another image in an HTML file? I want the superimposed image to stay within the boundaries of the underlying image. Any suggestions on how this can be achieved? <html& ...

How to cleanly print HTML pages with the use of page breaks

Having trouble with creating a table and printing the data in a specific structure. The format should be: Title Data Sum The challenge is to ensure that the title does not end up at the bottom of the page, and the sum does not start at the top of the pag ...

Adding <link> or <meta> tags to the <head> using HtmlAgilityPack: A comprehensive guide

The URL for downloading the documentation from is causing an error and I'm unable to resolve it despite multiple attempts. I am attempting to insert different tags into the <head> section of an HtmlDocument that I have loaded from an HTML stri ...