Animation of shaking CSS circles

I have been working on creating a circle using CSS, but I've run into some issues that I can't seem to fix. There are two main problems I'm facing:

  1. When viewed in Chrome: The circles shake while rotating.

  2. When viewed in Firefox: A tail-like dot appears when the circle is animating in circular motions.

This is the CSS styling I am currently using:

.followers_arc_outer{
    position:absolute;
    width:300px;
    height:300px;
    border-radius:100%;
    border:2px solid;
}
.followers_arc_start {
    border-color:transparent #ecd201 #ecd201 #ecd201;
    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    -o-transform: rotate(45deg);
    transform: rotate(45deg);
}
.followers_arc_inner{
    position:absolute;
    top:18px;
    left: 18px;
    width: 280px;
    height:280px;
    border-radius:100%;
    border:2px solid;
    border-color:transparent #ecd201 #ecd201 #ecd201;
}
.o_circle {
    -webkit-animation: rotation 2s infinite linear;
    animation: rotation 2s infinite linear;
}
@-webkit-keyframes rotation{
    from {-webkit-transform: rotate(0deg);transform: rotate(0deg);}
    to   {-webkit-transform: rotate(359deg);transform: rotate(359deg);}
}@keyframes rotation{
    from {-webkit-transform: rotate(0deg);transform: rotate(0deg);}
    to   {-webkit-transform: rotate(359deg);transform: rotate(359deg);}
}
.i_circle {
    -webkit-animation: rotation2 2s infinite linear;
   animation: rotation2 2s infinite linear;
}
@-webkit-keyframes rotation2 {
    from {-webkit-transform: rotate(359deg);transform: rotate(359deg);}
    to   {-webkit-transform: rotate(0deg);transform: rotate(0deg);}
}@keyframes rotation2 {
    from {-webkit-transform: rotate(359deg);transform: rotate(359deg);}
    to   {-webkit-transform: rotate(0deg);transform: rotate(0deg);}
}
<div class="followers_arc_outer followers_arc_start o_circle"></div>
    <div class="followers_arc_inner followers_arc_start i_circle"></div>

To see the issue for yourself, check out this fiddle link: http://jsfiddle.net/r8cqet2c/4/

Is there something I may be missing or doing incorrectly?

Answer №1

If your circles are large in size, it may cause browsers to struggle while rendering them. This becomes especially challenging when attempting to rotate and animate the circles smoothly, as the browser relies on CPU graphics by default.

However, you can enhance performance by utilizing your GPU within the browser through hardware-accelerated CSS. Applying the following code to your circles can help improve the fluidity of animations:

-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);

You can also use the alternative code below, both of which yield similar results:

-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-o-transform: translateZ(0);
transform: translateZ(0);

If you still encounter lag or unusual behavior, particularly in Chrome or Safari, consider adding the following additional code:

-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;

-webkit-perspective: 1000;
-moz-perspective: 1000;
-ms-perspective: 1000;
perspective: 1000;

We hope these suggestions prove helpful for optimizing your circle animations!

Answer №3

In my opinion, the issue may be related to anti-aliasing and rounding. After switching the background to solid black and halting the animations after one rotation, I noticed that when the circles are stationary, the anti-aliasing causes certain parts of the circles to appear less defined, particularly when zoomed in at a smaller scale. I did not observe any shaking or trailing effects.

Answer №4

Every scenario is causing a tremor After testing the code on Chrome, Mozilla, Opera, and even Safari (including version 5.17), everything seems to be working fine.

It's possible that the issue lies with your display resolution or a problem with your graphics card.

Answer №5

Everything looks good when viewed independently. (Tested on Chrome, Firefox, Safari)

In the event that you encounter any issues when viewing this content independently, it could be related to your device / hardware or browser configurations.

However, the shaking effect is likely being caused by some other conflicting code within your application interacting with this code.

Answer №6

One reason for this issue is anti-aliasing, but it can be resolved by smoothing the border using specific techniques. To prevent the problem, you can utilize the box-shadow property with the inset value rather than relying solely on color and solid properties:

Custom CSS Styling

.followers_arc_outer {
        position: absolute;
        width: 300px;
        height: 300px;
        border-radius: 100%;
        box-shadow: 2px 0px 2px 0px #ecd201 inset;
    }

    .followers_arc_inner {
        position: absolute;
        top: 18px;
        left: 18px;
        width: 280px;
        height: 280px;
        border-radius: 100%;
        box-shadow: 2px 0px 2px 0px #ecd201 inset;
    }
    

To observe how this solution works effectively, check out this demonstration on JSFiddle: http://jsfiddle.net/heartagramir/xdmuvu9s/

Answer №7

To ensure smoother transforms and avoid a choppy or ragged appearance, it is recommended to reset translate3d to zero:

.transform {
    -moz-transform: rotate(-4.7deg) translate3d(0, 0, 0);
    -ms-transform: rotate(-4.7deg) translate3d(0, 0, 0);
    -o-transform: rotate(-4.7deg) translate3d(0, 0, 0);
    -webkit-transform: rotate(-4.7deg) translate3d(0, 0, 0);
    transform: rotate(-4.7deg) translate3d(0, 0, 0);
}

It's advisable to always include translate3d(0, 0, 0) when utilizing transforms.

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

Which is better for cycling through a list of items: CSS or JavaScript?

Currently, I have a navigation bar set up as an unordered list (<ul>), but some list items are not visible. I want to implement functionality where clicking arrows will move the elements left or right by hiding or showing the leftmost or rightmost it ...

Is there a way to display only the specific child div within the parent div using JavaScript without affecting the others?

   **** Sorry for the lengthy title **** Today I encountered a problem that I would like to discuss with all of you. When I click on a "COMMENT" button, instead of triggering JavaScript code to display a CHILD.div inside the corresponding ...

What could be causing Prettier code formatter to suddenly stop formatting in VS Code?

I've been having trouble formatting my code using Prettier in VS Code. Even after reinstalling it, the issue persists and I can't seem to format my HTML/CSS code properly. The screenshot I provided shows that the code remains unformatted even aft ...

Having trouble with WordPress jQuery Click function. Would greatly appreciate some assistance :)

There seems to be a mix of working and non-working jQuery code. Specifically, the click function is not functioning properly in this case. Here is an example of the code that works: $j=jQuery.noConflict(); // Using jQuery with $j(...) $j(document ...

Scrollspy in bootstrap incorrectly highlights the navigation item as active

I seem to be having an issue with bootstrap scrollspy. For example: <header class="header pb-4 pb-lg-0 pt-4 sticky-top bg-white"> ... </header> <div class="container-fluid width content-main" data-bs-spy=" ...

Creating an online bidding platform using ASP.Net, MVC 5, and Entity Framework

Having recently delved into the world of ASP.NET, I am in the process of developing a basic auction site for a charitable cause. Utilizing MVC 5 and Entity Framework with Code-First approach for database management. The core of this project is the Item mo ...

Issues with displaying HTML video content

Seeking assistance with a unique coding predicament. I've got an HTML file that showcases a JavaScript-powered clock, but now I'm looking to enhance it by incorporating a looped video beneath the time display. Oddly enough, when the clock feature ...

JSON retrieved images are failing to appear in a grid layout

Hey there, I'm facing an issue with the layout of images on my website. I am fetching data from a JSON file to create a grid of images, but unfortunately, all the images are displaying in a single column instead of a grid. I am aiming for a 4 wide ima ...

Setting the height of children within an absolutely-positioned parent element

I am facing an issue with adjusting the size of children elements based on their parent. The scenario is as follows: HTML <div class="video"> <div class="spot"> <img src="..." alt=""> <button>x</button> </div ...

Adjusting Image Size with HTML and CSS

UPDATE* I am having an issue with the resizing of images on my website. The problem specifically pertains to the music tab where the image is not fitting within the div size properly. I have provided a screenshot for reference https://i.sstatic.net/Zbwag ...

What is the equivalent of a very deep selector in TailwindCSS?

When working with the v-deep selector to customize the appearance of tiptap, a rich text editor, accessing the .ProseMirror class in SCSS would look like this: editor-content { // ... styles &::v-deep(.ProseMirror) { // ... styles } } ...

What is the process for adjusting the font in my VS Code editor?

Currently diving into an Angular2 development video course, I stumbled upon something intriguing: https://i.stack.imgur.com/CIBcx.jpg Yes, aesthetically pleasing HTML attributes won't make me a coding genius. But let's be honest, who doesn&apos ...

Element sticking on scroll down and sticking on scroll up movements

I am currently working on a sticky sidebar that catches and stays fixed at a certain scroll point using JavaScript. However, I am facing an issue where I need the sidebar to catch when scrolling back up and not go further than its initial starting point. ...

Is it possible to incorporate shadows on a pie chart using recharts?

Does anyone know how to enhance a pie chart with shadows using the recharts library? https://i.sstatic.net/JLGVF.png https://i.sstatic.net/f5qv4.png If you have any solutions, please share. Thank you! ...

What is the best way to transfer a JavaScript variable through a query string from one HTML page to another?

Is there a way to pass a JavaScript variable called username from one HTML page, example1.html, to another HTML page, example2.html, using query strings? <script type="text/javascript" > $(document).ready(function() { $('#SubmitForm ...

React does not recognize CSS attributes

I am facing an issue with the CSS styling when using built-in tags like "form-group" in my code. Strangely, the browser does not apply the CSS when I use these built-in tags. However, if I define my own classes, such as "classes.form", the CSS is visible i ...

Alternating CSS Designs for Displaying Multiple Mysql Query Results

I have a website where users can search for a specific product in their location, and the site will display a list of results. if(isset($_POST['zip'])){ $qry="SELECT business_id FROM ".TBL_BUSINESS." WHERE zip LIKE '%".$_POST['zip&apos ...

How to Build Two Navbars in BootstrapVue with a Sticky Bottom Navbar at the Top

My current project involves creating two navigation bars. The first navbar at the top consists of just a brand logo, while the second navbar at the bottom serves as the main navigation menu. I want the top navbar to scroll off the screen when users scroll ...

Ensure that each of the two divs maintains a 16:9 aspect ratio, and utilize one div to fill any remaining empty space through the

This layout is what I am aiming for: https://i.sstatic.net/uZdty.png While I can achieve a fixed aspect ratio with a 16:9 image by setting the img width to 100%, I run into an issue where the height scaling of flexbox becomes non-responsive. The height re ...

Removing HTML elements with jQuery's .html() method

I have a scenario where I am storing the complete content of a <tbody> in a variable, and after some table manipulation, I need to revert back to the original content of the <tbody>. However, when I try to switch back to the original content, j ...