Do CSS have a conflict resolution rule? While my fadein keyframes function perfectly, I encounter issues with my slidedown animation

Using react and css, I have created two animations in my css file:

@keyframes fadein {
    0% {
        visibility: hidden;
        opacity: 0;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        visibility: visible;
        opacity: 1;
    }
}

@keyframes slidedown {
    0% {
        transform: translateY(0%);
    }
    100% {
        transform: translateY(30%);
    }
}

.welcome__text {
    padding: 3rem;
    animation: 
        /* slidedown 2s ease 0s 1 normal forwards; => This one doesn't work */
        /* fadein 1s ease-in 0s 1 normal forwards; => This one works */
}

Below is the code for my react file:

const Home = () => {
    return (
        <div className='homepage'>
            <div className='welcome__text'>
                <h1>Welcome</h1>
                <h3>to Net's Web Game</h3>
            </div>
        </div>
    )
}

export default Home;

The fadein animation works fine, but the slidedown animation does not. I am unsure of what could be causing this issue. Could there be a conflict with another css rule?

Answer №1

If you want to apply two animations to the same element, make sure to separate them with commas. Otherwise, only the last animation (in this case, fadein) will take precedence as CSS is interpreted from top to bottom. To define the animation properties, also separate them with commas. Here's an example:

@keyframes fadein {
  0% {
    visibility: hidden;
    opacity: 0;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    visibility: visible;
    opacity: 1;
  }
}

@keyframes slidedown {
  0% {
    transform: translateY(0%);
  }
  100% {
    transform: translateY(30%);
  }
}

.welcome__text {
  padding: 3rem;
  animation: slidedown 2s, fadein 1s;
  animation-fill-mode: forwards;
  animation-timing-function: ease 0s, ease-in 0s;
  animation-direction: normal;
  /* slidedown 2s ease 0s 1 normal forwards; => This one doesn't work */
  /* fadein 1s ease-in 0s 1 normal forwards; => This one works */
}
<div class="welcome__text">hey there!</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

What are the steps for defining a package once and utilizing it across multiple pages?

Hello, I'm new to Next.js and I have a question regarding the code organization. In my project, I have two pages: PostList (index.js) and PostSingle ([postId].js). I want to implement a feature that allows users to switch between dark and light theme ...

Creating a unique Link component for Next.js: A step-by-step guide

Is there a way to create a custom Link component in Next.js? I require a custom Link component that allows for a conditional onClick event. It will be cumbersome to add this functionality to each <Link><a onClick={handleClick}</a></Link&g ...

How to display percentage value on ReactJS Material UI progress bar

For displaying the progress completed in numbers, I utilize the Linear Determinate component. Take a look at the image below to see how it appears. ...

Loading menu items into MUI Select from a JSON file

Looking to dynamically populate an MUI select with choices retrieved from an API's JSON response. Currently, all Choices are being inserted into a single MenuItem within the Select component. Considering that the Choices may change in the future, I&a ...

Is there a way to incorporate content onto a webpage solely through the use of CSS and JavaScript?

Currently, I am in the process of developing a real estate website that utilizes a paid service for displaying real estate listings. The unique aspect of this setup is that my website operates as a subdomain of the main listings website, resulting in a URL ...

What methods are available to limit users on an OTT platform (such as restricting each account to 3 streams on different devices)?

Currently, I am developing an OTT platform that utilizes Django Rest Framework for API, React for website development, and React Native for app creation. I have a challenge where I need to implement device limitations on user accounts, allowing only 3 use ...

Middle position of the rotating display

Currently working on a shop's image carousel where I'm implementing scroll-snap-type: x mandatory; for the container and scroll-snap-align: center; for the images. However, running into a challenge where the container sometimes exceeds the width ...

Exploring ways to maximize the width of responsive images on a webpage

I am currently working on a website located at . The slider image dimensions are set to 800x400, but the height appears too large. I need assistance in making the slider images responsive while maintaining their full width without sacrificing height. Ple ...

Guide to handling disabled dates in the react-date-range component

I am seeking guidance on how to handle disabled dates that are not included in the availableDates state. This feature is crucial for booking travel. 'use client'; import axios from 'axios'; import { useEffect, useState } from 'rea ...

Tips on displaying a single column in Bootstrap when only one item is present and switching to two columns when two items are present

Currently, I am utilizing the row class in Bootstrap which contains two columns, one for X and one for Y. There are scenarios where either the X column, the Y column, or both may be present within the row. Since a row can have up to 12 columns, when only t ...

Incorporate an onclick event to the elements within the array

I'm currently working on iterating over an array and adding an onclick event to each element. My goal is to be able to click on each div and have them log their values in the console. However, I am facing a challenge in applying the onclick event to e ...

While browsing in Firefox and moving the cursor over a sub element

While hovering over a child element in Firefox using the rule .parent:hover > .child { /*style*/ }, the child element is considered separate from the parent element and does not receive styling. For example, in Firefox when you hover over the button, on ...

I'm looking to use JavaScript to dynamically generate multiple tabs based on the selected option in a dropdown menu

I'm reaching out with this question because my search for a clear answer or method has come up empty. Here's what I need help with: I've set up a dropdown titled 'Number of Chassis'. Depending on the selection made in this dropdown ...

What causes a standard React component with a default render prop to not pass PropTypes validation successfully?

I'm currently working on a React component with a render-prop that has a generic type. To improve usability, I want to set a default value for the render-prop. The code is functioning correctly, but during type-checking, I encountered a warning regard ...

How can I vertically align a label placed in a horizontal row in a Material UI grid that includes an InputLabel and Input?

I am working on a React Material UI grid layout with InputLabel's and Input fields displayed in a horizontal row. Here is the code snippet: const Container = (props) => <Grid container {...props} />; const Item = (props) => <Grid item x ...

What is the method for altering the appearance of grid columns with javascript?

What modifications do I need to make in JTML and Javascript? var opac; function checkfun() { opac=(Array.from(document.querySelectorAll('input[type="checkbox"]')) .filter((checkbox)=>checkbo ...

Ways to enable file/result downloads on a website using HTML

Could you please take a look at this repository: https://github.com/imsikka/ArtGallery I am looking to create a downloadable result using a download button. I can create the button, but I am unsure of how to make the file actually downloadable. Do I need ...

Properly configuring paths in react-native for smooth navigation

When working on my React-Native project, I noticed that my import paths look something like this: import { ScreenContainer, SLButton, SLTextInput, } from '../../../../../components'; import { KeyBoardTypes } from '../../../../../enums ...

Why do div and span display differently across browsers and how can we standardize their appearance?

My CSS file is currently displaying correctly in FF12, but the layout is different in Safari and Chrome. If images are not loading, you can view a live demo at This is how it should appear and does in FF: However, this is what happens in Safari and Chro ...

Utilize the Power of JQuery Range Slider to Dynamically Update CSS Property Values (specifically column / fr and column-gap)

Currently, I am in the process of creating a JQuery range slider that can dynamically update the columns and column-gaps of my photo grid. While searching for a solution, I came across a relevant post where someone had shared their code. However, there see ...