Firefox experiencing glitchy rotation in CSS animations

I attempted to create a rotating div using a simple code snippet:

<!DOCTYPE html>

<html>
<head>
<style>
.spinner {
  width: 100px;
  height: 100px;
  margin: auto;
  border-radius: 50%;
  border-bottom: 1px solid #f00;
  animation: rotate-bottom 1s linear infinite;
}

@keyframes rotate-bottom {
  from {
    transform: rotateX(30deg) rotateY(-60deg) rotateZ(0deg);
  }
  to {
    transform: rotateX(30deg) rotateY(-60deg) rotateZ(360deg);
  }
}
</style>
</head>
<body>
<div class="spinner"></div>
</body>
</html>

After sharing the code on jsfiddle for testing: http://jsfiddle.net/zg8vdyns/1/

The rotation appears smooth and flawless in Chrome and Internet Explorer. However, there are issues when viewed in Firefox (39.0). The spinning line is shorter than expected and the animation does not run smoothly, suggesting a possible rendering problem exclusive to Firefox. Any suggestions or insights regarding this issue would be greatly appreciated.

While I am aware of the need to prefix 'animation' and keyframe properties with '-moz-', it seems unrelated to this specific problem.

Answer №1

Your issue revolves around the intricacies of half-pixel/sub-pixel rendering. Experimenting with changing the CSS property from border-bottom: 1px solid #f00; to border-bottom: 3px solid #f00; reveals that while the animation remains intact, the rendering differs significantly across various browser engines... As pointed out in another Stack Overflow post: Firefox CSS Animation Smoothing (sub-pixel smoothing)

It's evident that each browser implements its rendering engine differently. Firefox, for instance, doesn't apply anti-aliasing to CSS animations. This distinction isn't inherently favorable or unfavorable; it simply varies based on the content being animated. For example, linear transitions might appear overly blurred in Chrome.

If your goal is to achieve smoother transitions with anti-aliased/sub-pixel smoothing, we can't alter the rendering engine itself but we can tweak the animation to appear more polished to users.


In contrast to the method suggested in the linked answer, I believe there's a simpler way to ensure uniform rendering: http://jsfiddle.net/zg8vdyns/7/

By adding

border-left: 1px solid rgba(255, 0, 0, 0.7);
, you essentially "prompt" FireFox to render the half-pixels/sub-pixels that it normally wouldn't...

Update:

@joshin855 also proposed a fantastic solution below: introducing the property

background:rgba(255,255,255,0.01);
similarly encourages the rendering of half-pixels/sub-pixels. While this approach may feature a filled circle that isn't suitable for all scenarios, the line animation could be even more consistent compared to my suggestion... Hence, it presents another viable option.

Answer №2

To address the issue of the line appearing as a dot, one solution is to add either background:white; or background:RGBA(255,255,255,.01); to the element. This should resolve the problem and ensure consistency across different browsers. While this may not be the perfect solution, I wanted to offer my input on the matter.

.spinner {
  width: 100px;
  height: 100px;
  margin: auto;
  border-radius: 50%;
  border-bottom: 1px solid #f00;
  animation: rotate-bottom 1s linear infinite;
  background:RGBA(255,255,255,.01);
}

http://jsfiddle.net/fqqko0uv/2/

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

AngularJS button click not redirecting properly with $location.path

When I click a button in my HTML file named `my.html`, I want to redirect the user to `about.html`. However, when I try using `$location.path("\about")` inside the controller, nothing happens and only my current page is displayed without loading `abou ...

Include new items in the li tag using JavaScript

Hello, I am looking to dynamically add elements to an LI element when a link is clicked. I have successfully added elements to a DIV using the following code snippet: I came across a similar question on Which "href" value should I use for JavaScript links ...

Is conditional CSS possible with NextJS?

While working on an animated dropdown for a navbar, I came across this interesting dilemma. In a strict React setup, you can use an inline if/else statement with onClick toggle to manage CSS animation styles. To ensure default styling (no animation) when ...

Customize the background image in your Windows 8 app developed with HTML

While working on my app with the grid app template, I placed an image in the images folder. However, when I attempted to change the background image, it didn't seem to take effect. This is the code snippet that I used: HMTL <div id="contenthost" ...

Adjusting the color of a value in justGage requires a few simple steps to

Is it possible to modify the color and design of the text in the Value parameter of justGage after creating the gauge? My goal is to change the text color to blue with an underline to give it a link-like appearance. Appreciate your assistance. ...

The modal dialog feature in HTML5 and CSS3 seems to be experiencing some issues when used in Opera browser

This informative post provides a detailed tutorial on creating a modal dialog using only HTML and CSS3. For more information, visit: To see a working demo, click here: The modal works flawlessly in most browsers, but some users have reported issues with ...

Can data be transferred between browsers, such as from Google Chrome to Mozilla Firefox?

I have a dilemma with two separate pages—one for Admin and the other for User. The Admin page is named index.html <!DOCTYPE html> <html lang="en"> <head> <style> * { padding: 0; ...

Trouble with implementing conditional styles in Next JS

<label className={`${darkModeActive ? 'text-brand-five' : 'text-brand-seven'} ${errors.invoiceDate ? 'text-[#EC5756]' : ''}`} htmlFor="invoiceDate"> Invoice Date </label> I am encountering a ...

To emphasize code in an HTML document, you can use the <font color="#xxx"> tag

Can anyone guide me on how to add color highlights to my HTML code in this way? <font color="#1773cc">#include </font><font color="#4a6f8b">&lt;NTL/ZZ.h&gt;</font><br> <br> <font color=&quo ...

trigger jquery popup from server-side code (ASP.Net VB)

Within my code, I have created a div element which serves as a popup message: <div class="info message"> <h3>Informa&ccedil;&atilde;o</h3> <p>Mensagem informativa.</p> </div> In addition, ther ...

Whenever I nest my div tags within another div element in an HTML document

Whenever I try to position a div inside another div using float, I encounter problems. <div id="main"> <div id="anotherDiv"> <h1>Test</h1> </div> </div> Here is the corresponding style sheet: #main{ ba ...

the styling gets disrupted by the addition of grid columns

Looking for help with aligning and spacing three sets of strings in a single line while maintaining grid columns intact, even when window size is reduced. Currently experiencing alignment issues like this: https://i.stack.imgur.com/iqlam.png Tried removi ...

Struggling with a JQuery function that fails to perform addition

I'm experiencing an issue with my code where the math doesn't add up when trying to sum values under the venting selection. Instead of adding up, it just displays as text. I have an event set up that should populate the values upon selecting valu ...

Form on the internet with a following button

Currently working on a basic form: <tr> <td> <label for="FirstName">First Name <span class="req">*</span> </label> <br /> <input type="text" name="FirstName" id="FirstName" class="cat_textbox" ...

Discover the sleek and modern concept of transparency in Microsoft's

I'm interested in incorporating Microsoft Fluent Design transparency into my webpage. Are there any CSS or other tools that can help achieve this design language? I want to enhance the look of my site with these elements. ...

What causes the image to vanish once the CSS animation is activated?

Is there a reason why the image disappears after the animation completes? :/ .coin { width: 200px; height: 200px; background-size: cover; animation: CoinflipRoll 6s steps(199); animation-delay: .5s; animation-fill-mode: forwards; ...

Update the text in a personalized dropdown menu when an option is chosen

After spending some time working on a customized dropdown with the use of CSS and Vanilla JavaScript (Plain JS), I encountered an issue while trying to select and update the dropdown text upon clicking an option: window.onload = () => { let [...opt ...

I need help figuring out how to create dynamic bars that change colors based on their values. Any suggestions on how to

Seeking a solution to create interactive live-charts similar to the image provided. I've explored various chart libraries like Highcharts, fusioncharts, raphaeljs and many others, but haven't found one that fits my needs perfectly. I experimented ...

What are some creative ways to customize the background of a full component?

Is there a way to modify the background color of an entire component? I want the color to cover the full width and height of the component. I attempted using the body tag, but it was ineffective. Do I need to enclose all components in a div and then appl ...

Generating a hyperlink to a specific user ID within a data table

I'm facing an issue with the formatting of my simple table when trying to navigate to user.id. Is there a better approach to this or should I consider moving LinkToUser? All styling has been removed to avoid any conflicts. import styled from 'st ...