Animated border CSS is malfunctioning specifically on Firefox: The CSS code consists of a blend of tailwind classes and personalized CSS styling

I'm having an issue with the animated border on Firefox. It works perfectly on Chrome, but on Firefox, the border doesn't show up at all and the animation is not working. I need some help with this.

Here is the CSS file:

@import "keyframes.css";

@layer components {
  .animated-chevron {
    @apply relative;
    &:before {
      @apply content-[''] absolute w-0 h-[0.18rem] top-[41%] right-[-0.05rem] mr-[0.5rem] bg-current rounded group-hover:w-[0.55rem] group-hover:md:w-[0.7rem] transition-all duration-medium;
    }
  }
}

@layer utilities {
  .splash {
    @apply relative overflow-hidden;
    &:after {
      @apply content-[''] absolute block bg-white w-0 h-0 hover:w-[100%] hover:h-[100%] top-1/2 left-1/2 opacity-[0.15] rounded-full -translate-x-1/2 -translate-y-1/2 transition-all duration-long;
    }
  }
  .animated-border {
    @apply relative;
    &:before,
    &:after {
      -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
      -webkit-mask-composite: xor;
      mask-composite: exclude;
      @apply content-[''] absolute inset-0 rounded-primary border-[1.5px] border-transparent filter contrast-[6] bg-current pointer-events-none transition-all duration-1000;
    }
    &:after {
      background: linear-gradient(var(--angle), var(--tw-gradient-stops)) border-box;
      @apply animate-[rotate_4s_linear_infinite] opacity-0 hover:opacity-100;
    }
  }
  .animated-border-static {
    @apply animated-border from-primary-light via-black via-[70%] to-gray-light after:opacity-100;
    &:before {
      all: unset;
    }
  }
}

JSX file:

import { twMerge } from "tailwind-merge";

const StatusCard = ({ className, title, subtitle, icon: Icon }) => {
  return (
    <div
      className={twMerge(
        "group w-full flex flex-col place-items-center relative py-5 px-3 md:py-7 md:px-7 gap-1 animated-border-static revert",
        className
      )}
    >
      <div className="opacity-80 mb-3 transform scale-75 md:scale-100 rounded-2xl p-5 flex aspect-square rotate-45 md:mt-2 bg-gray-200">
        <Icon className="w-8 h-8 -rotate-45 fill-black" />
      </div>
      <span className="font-semibold text-sm md:text-base -mt-3 md:mt-2">{title}</span>
      <span className="font-medium text-sm md:text-base">{subtitle}</span>
    </div>
  );
};

export default StatusCard;

Keyframes.css

@property --angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

@keyframes rotate {
  to {
    --angle: 360deg;
  }
}

When I comment out the :

:before {
all: unset;
} 

The border starts showing up in Firefox, but the animation still isn't working. It seems like Firefox may have an issue with pseudo-selectors.

Answer №1

As stated on MDN, the @property at-rule is not supported by Firefox currently. This results in the absence of a default value for --angle. Consequently, the linear-gradient() value within the background declaration in the .animated-border:after rule would be deemed invalid:

.animated-border:after {
  background: linear-gradient(var(--angle), var(--tw-gradient-stops)) border-box;
}

In order to ensure that the animated border displays correctly in Firefox, it may be beneficial to include the default value "inline":

.animated-border:after {
  background: linear-gradient(var(--angle, 0deg), var(--tw-gradient-stops)) border-box;
}

const Icon = () => "icon"

const StatusCard = ({ title, subtitle }) => {
  return (
    <div
      className="group w-full flex flex-col place-items-center relative py-5 px-3 md:py-7 md:px-7 gap-1 animated-border-static revert"
    >
      <div className="opacity-80 mb-3 transform scale-75 md:scale-100 rounded-2xl p-5 flex aspect-square rotate-45 md:mt-2 bg-gray-200">
        <Icon className="w-8 h-8 -rotate-45 fill-black" />
      </div>
      <span className="font-semibold text-sm md:text-base -mt-3 md:mt-2">{title}</span>
      <span className="font-medium text-sm md:text-base">{subtitle}</span>
    </div>
  );
};

ReactDOM.createRoot(document.getElementById('app')).render(<StatusCard title="Foo" subtitle="Bar"/>);

tailwind.config = {
  theme: {
    extend: {
      colors: {
        'primary-light': 'red',
        'gray-light': 'lightgray',
      },
      borderRadius: {
        primary: '20px',
      },
    },
  },
};
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.min.js" integrity="sha512-8Q6Y9XnTbOE+JNvjBQwJ2H8S+UV4uA6hiRykhdtIyDYZ2TprdNmWOUaKdGzOhyr4dCyk287OejbPvwl7lrfqrQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js" integrity="sha512-MOCpqoRoisCTwJ8vQQiciZv0qcpROCidek3GTFS6KTk2+y7munJIlKCVkFCYY+p3ErYFXCjmFjnfTTRSC1OHWQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdn.tailwindcss.com/3.3.2"></script>

<div id="app"></div>

<style type="text/tailwindcss">
@property --angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

@keyframes rotate {
  to {
    --angle: 360deg;
  }
}

@layer utilities {
  .animated-border {
    @apply relative;
  }
  .animated-border:before,
  .animated-border:after {
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    @apply content-[''] absolute inset-0 rounded-primary border-[1.5px] border-transparent filter contrast-[6] bg-current pointer-events-none transition-all duration-1000;
  }
  .animated-border:after {
    background: linear-gradient(var(--angle, 0deg), var(--tw-gradient-stops)) border-box;
    @apply animate-[rotate_4s_linear_infinite] opacity-0 hover:opacity-100;
  }
  .animated-border-static {
    @apply animated-border from-primary-light via-black via-[70%] to-gray-light after:opacity-100;
  }
  .animated-border-static:before {
    all: unset;
  }
}
</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

Encountering a 500 error while attempting to pass HTML via an AJAX call to a C# MVC Controller

Currently facing a challenge that I need help with. I have multiple pages successfully making Ajax calls to my C# controllers, but now I'm trying to incorporate a simple content management feature. The goal is to update HTML stored in a database with ...

Create a stylish Bootstrap 3 modal featuring an image and convenient scroll bars

My dilemma is with a modal dialog containing an image of fixed width set at 1500px. I want the image to maintain this size and for scroll bars to appear on smaller screen sizes, allowing users to scroll through the entire image. Essentially, I need the mod ...

What could be causing sporadic disappearance of my background image?

Feeling overwhelmed by this sudden issue on my WordPress site. The logo isn't working properly, and I've saved this page as HTML for reference. Check out the link: Oddly enough, leaving a page open for a while or navigating away and returning t ...

Suggestions on designing a website's layout

Currently, I am in the process of designing a website that is tailored to perfectly fit within the browser window. Here's a brief overview of the layout: At this point, the Red area is set as display:block, while the Green area has been configured wi ...

What is the best way to retrieve the response from an API call and showcase it in my component?

My AuthContext includes a reducer, actions, and api calls that handle user authentication. AuthReducer: case "LOGIN_FAILURE": return { user: null, isFetching: false, error: true, }; Au ...

React: The `style` attribute requires a key-value mapping of style properties, rather than a simple string

I am attempting to use React to render the following HTML code: <a style='background-color:black;color:white;text-decoration:none;padding:4px 6px;font-family:-apple-system, BlinkMacSystemFont, "San Francisco", "Helvetica Neue", Helve ...

What could be causing htmlparser2 in Node.js to add extra nodes during document parsing?

Seeking to extract the HTML content of a webpage using node so I can process its DOM to create something unrelated. It's crucial to accurately obtain the DOM representation from the HTML in order to properly process it. Utilizing htmlparser2 for this ...

Control the Bootstrap carousel with a custom Javascript function for playing and pausing

Having an issue with the carousel class in Bootstrap. I have a button that defaults as a pause button, and then I use a JavaScript function on that button to control the carousel. When clicked, the icon should change to play and the carousel should stop cy ...

``The text overlay feature on the image appears to be malfunctioning

I'm facing an issue with overlaying text on an image - the text is getting pushed underneath the image and not displaying as intended. I can't figure out what's causing this problem. Any assistance would be greatly appreciated. Below is the ...

Tips for implementing a jQuery mouseleave function for multiple div elements sharing the same id

I am facing an issue with my website where multiple divs share the same id. I need to implement a mouseleave function for all of these divs that have this specific id. Within my $(document).ready function, I currently have the following code... $('#m ...

Click once to reveal, click twice to conceal the slider

I currently have a web page set up so that a single click on the text displays a slider for selecting a range of values. Now, I want to incorporate a feature where a double click will remove the slider. Below is the HTML code: <!DOCTYPE html> < ...

View two tiled images side by side and seamlessly load them in real-time with our innovative image viewer

Currently, I am working on creating a webpage where two tiled images can be loaded and displayed side by side. The goal is for these images to zoom in together but remain separately tiled. After doing some research, it seems that using Seadragon may not al ...

How to Overcome Read-only HTML Components in Selenium with Python?

I am working on automating a task using Selenium in Python, and part of it involves selecting a date. The website I am testing has an input box for date selection that displays a standard date table when clicked. Unfortunately, the input text box is read- ...

Efficiently determine optimal menu item dimensions using CSS automatically

Is it possible to automatically position menu items using CSS so that the position is recalculated when the menu item text changes? Currently, I have a menu created with ul li's and I am using padding for positioning. However, if the text becomes long ...

The functionality of the dropdown link in the Bootstrap navbar is disrupted if the bootstrap.min.js file is included in the

I am a newcomer, so please be patient with me. I took this navbar code from Bootstrap and made some adjustments to fit it into my project. Within a dropdown list are three dropdown items. My goal is to give users two options: either go directly to the por ...

Adjust the loading of parameters in Selectize

selectize({ valueField: 'Id', labelField: 'Name', searchField: 'Name', load: function (query, callback) { $.ajax({ url: '/some_url/params?SOME_ID=4&keyword=& ...

Using AngularJS: Verify the presence of a key/value pair in an object and create an array of objects

My current service method retrieves income data from different projects and creates a new array of objects. I am seeking assistance to sort this array by year and trimester in order to simplify looping through it using ng-repeat in the view. The data stru ...

Getting the string value from query parameters can be achieved by accessing the parameters and

Currently, I am attempting to retrieve the string value stored within a class-based object variable named question5. The way I am trying to access this variable on the front-end is shown below. axios.get("http://localhost:3001/users/questionaire/?getq ...

Running unit tests to verify that the ng-if divs are properly displaying

Inspired by this particular question, I have implemented a method to test the correct display of ng-if tagged divs using Karma instead of Protractor: var element; beforeEach(inject(function ($rootScope, $templateCache, $compile) { scope = $rootScope.ne ...

Designing HTML Emails Using Nested Tables

Why is my text-decoration="none" not displaying properly? I have tried placing it in various locations like table, tr, td, but I am unable to make it work. Are there any common mistakes when styling email designs? Here is the code snippet: <table cel ...