Troubleshooting CSS animation glitches on Firefox

Trying to rotate 2 cards, one containing an icon and the other a value The HAML snippet for this is:

.card
        .side.back
          %span.txt {{ notifications.length }}
        .side
          %i.material-icons.small_icon remove_red_eye

This setup works perfectly in Chrome/Chromium and Opera, however, in Mozilla Firefox, the eye icon appears together with the data value. To address compatibility with Mozilla, my CSS snippet includes:

.card{
-moz-animation-name: spin;
-moz-animation-duration: 2500ms;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: linear;
}

@-moz-keyframes spin{
        from { -moz-transform: rotateY(0deg); }
        to { -moz-transform: rotateY(360deg); }
    }

Any suggestions on how to resolve this issue?

.card .side {
  backface-visibility: hidden;
  border: none;
  background: #fafafa;
  border-radius: 0px;
  height: 100%;
  width: 100%;
}
.card .back {
  font-size: x-small!important;
  transform: rotateY(180deg);
}
.card {
  transform-style: preserve-3d;
  height: 100%;
  position: absolute;
  width: 100%;
  animation: spin 2500ms linear infinite;
}

@keyframes spin {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}
.small_icon {
  font-size: x-small!important;
}
.badge1 {
  position: absolute;
  top: 7px;
  left: 100px;
}
<div class="badge1">
  <div class="card-container badge1"></div>
  <div class="card">
    <div class="side back">
      <span class="txt">10</span>
    </div>
    <div class="side">
      <i class="material-icons small_icon">remove_red_eye</i>
    </div>
  </div>
</div>

Answer №1

Why not give this a shot:

.box{
-moz-animation-name: rotate;
animation-duration: 2500ms;
animation-iteration-count: infinite;
animation-timing-function: linear;
}

@keyframes rotate{
        from { transform: rotateY(0deg); }
        to { transform: rotateY(360deg); }
    }
<div class="box">
            <div class="side bottom">
             <p>Hello World</p>
            </div>
            <div class="side top">
             <i class="icon">X</i>
            </div>
          </div>

Answer №2

Something seems off here, and I'm not entirely sure what the issue is or whose code is correct.

Firefox appears to have a problem with your front element lacking its own transform outside of the animation.

This seems to cause the loss of transform-style: preserve-3d.

To resolve this, you can try these two workarounds:

  • Add an initial transform: rotateY(0);.

    .card .side {
      backface-visibility: hidden;
      border: none;
      background: #fafafa;
      border-radius: 0px;
      height: 100%;
      width: 100%;
      /* keeps Firefox happy */
      transform: rotateY(0deg);
    }
    .card .back {
      font-size: x-small!important;
      transform: rotateY(180deg);
    }
    .card {
      transform-style: preserve-3d;
      height: 100%;
      position: absolute;
      width: 100%;
      animation: spin 2500ms linear infinite;
    }
    
    @keyframes spin {
      from { transform: rotateY(0deg); }
      to { transform: rotateY(360deg); }
    }
    .small_icon {
      font-size: x-small!important;
    }
    .badge1 {
      position: absolute;
      top: 7px;
      left: 100px;
    }
    <div class="badge1">
      <div class="card-container badge1"></div>
      <div class="card">
        <div class="side back">
          <span class="txt">10</span>
        </div>
        <div class="side">
          <i class="material-icons small_icon">remove_red_eye</i>
        </div>
      </div>
    </div>

    • Add transform-style: preserve-3d back to your inner elements

    .card .side {
      backface-visibility: hidden;
      border: none;
      background: #fafafa;
      border-radius: 0px;
      height: 100%;
      width: 100%;
      /* keeps Firefox happy */
      transform-style: preserve-3d;
    }
    .card .back {
      font-size: x-small!important;
      transform: rotateY(180deg);
    }
    .card {
      transform-style: preserve-3d;
      height: 100%;
      position: absolute;
      width: 100%;
      animation: spin 2500ms linear infinite;
    }
    
    @keyframes spin {
      from { transform: rotateY(0deg); }
      to { transform: rotateY(360deg); }
    }
    .small_icon {
      font-size: x-small!important;
    }
    .badge1 {
      position: absolute;
      top: 7px;
      left: 100px;
    }
    <div class="badge1">
      <div class="card-container badge1"></div>
      <div class="card">
        <div class="side back">
          <span class="txt">10</span>
        </div>
        <div class="side">
          <i class="material-icons small_icon">remove_red_eye</i>
        </div>
      </div>
    </div>

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

Sending the $scope.master data to the subsequent form

I have a data set stored in the $scope.master array, and I have attempted to pass this information when submitting the form as shown below: <form novalidate class="css-form" method='post' action='www.example.com'> <INPUT type= ...

Clicking on the Bootstrap tabs causes them to shift position

I have come across an unusual issue with my website. While on the home page, clicking on a tab functions normally. However, when attempting to switch from one tab to another (such as News to Beats, Beats to News, News to Home, or Beats to Home), the tab co ...

Is it possible to save a dynamic web page to a file?

I am a beginner C++ programmer diving into the world of web development for the first time. My current challenge involves finding a way to continuously capture and save the HTML content of a constantly updating third-party website onto a static HTML file ...

issues with laravel blade form not redirecting to a specified route

I'm diving into named routing with Laravel 5.5 and encountering an odd issue while trying to handle a form action. Setups and Explanations: I defined my routes in web.php Route::post('questions/save_bulk', 'QuestionsController@sa ...

Creating a mobile-friendly layout with 3 columns: Tips and tricks

I attempted to solve the issue independently but didn't have much success. My goal is to create a proper version for mobile users using bootstrap, however, it currently looks terrible on mobile devices. I suspect the problem lies with the div classes ...

Navigating through CSS and working with partially cropped corners

I created a png file of a rounded rectangle in Photoshop, but noticed that parts of the image are getting cropped at the top right, bottom right, and bottom left corners, resulting in a square shape overall. Only the top left corner retains its rounded edg ...

Ways to dynamically activate an anchor tag's click event using JavaScript?

I'm having trouble triggering an already written click event for an anchor tag using JavaScript. Can someone help me figure out how to do this? I have the following anchor tag: <a id="memberid">Data Member</a> <script> $("#memb ...

How to wrap a narrower column around a shorter column using Bootstrap 4

Incorporating Bootstrap 4 into my website design, I have created a simple two column layout. The right column houses a table of contents while the left column is filled with various markup elements such as paragraphs, lists, and images. My goal is to have ...

What could be causing the lack of changes when trying to use justify content within the parent div?

I've been delving into CSS and trying to utilize justify-content in flex to center my content, but unfortunately, it's not cooperating. Here is the code I'm working with: .top-container{ display: flex; flex-flow: row nowrap; ma ...

HTML forms are larger in size on web pages than in Internet Explorer

https://i.stack.imgur.com/bUPtm.png I have posted the issue, and it is predominantly visual in nature. When viewed on a web browser within a C++ interface, the HTML appears significantly distorted. ...

What steps should I take to ensure that the login page functions properly?

Below is the HTML code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Login Pag ...

Using React Native to display an SVG path inside an SVG viewbox

I'm working on incorporating a barcode scanner viewfinder with an SVG icon to enhance its appearance. However, I am facing difficulty in making the path element within the SVG take up the full width and height of the SVG. In my React Native project, I ...

What are the options for transferring information between HTMX and Flask using JSON or another format aside from HTML?

So I am currently working on an app using Flask and HTMX. While I understand that htmx requires data in HTML format to swap with a specific target element, I am wondering if there is a way to update the current page using different formats such as dictiona ...

What are some ways to prevent an image from spilling out of its designated container

Despite my attempts at researching and seeking advice from someone more experienced in CSS styling, we were unable to find a solution to this issue. You can view the JS Fiddle link here: https://jsfiddle.net/haha78sr/. The image with the id, ctl00_cphB ...

Is my utilization of Flexbox and media queries incorrect?

Currently, I am practicing flexbox and breakpoints in material UI using React.js and I am attempting to achieve a layout similar to this: https://i.sstatic.net/vAkdo.png My goal is to have the product images and type displayed in columns, while the produc ...

An easy guide on implementing the if control statement within a Jinja2 embedded HTML document

Utilizing parsehub, I have successfully scraped a list of movie names and exported it to an html file using a python script. However, my intention is to only display titles that contain the word "The" by implementing an if statement. The code structure app ...

Guide to displaying names in PHP/HTML organized by group or rank

I am in the process of setting up a NASCAR league for my family members and I am currently developing a roster page where they can easily add or remove drivers. How can I display the drivers according to their rank as stored in the database? (A/B/C/D/E gro ...

Please click on the element located in the top right corner of the image

I am attempting to place a font icon in the top right corner of some images, with the intention of only triggering an event when I click on the icon. However, my current setup causes the entire image to trigger the click event. How can I restructure this t ...

When utilizing the --watch flag, Node-sass will fail to function properly

Encountering an issue with the "--watch" or "-w" flag when running node-sass. After installing node-sass as a devDependency and setting up a script to compile SCSS code, everything runs smoothly without any flags. However, adding the "--watch" flag causes ...

Developing a customizable datepicker with the ability to select specific months or date ranges

I am currently developing a WebApp using flask and constructing templates in HTML/JS for the front end. I am in need of a datepicker that will provide the user with the option to choose a specific date range or select a range of months. Take a look at the ...