import React from 'react';
function App() {
const myStyle = {
animation: 'fadein 0.5s, fadeout 0.5s 3s'
};
return (
<>
<div className='app' style={myStyle}>
</div>}
</>
)
}
export default App;
How can I write multiple css property value into react? A CSS property animation have two value i.e fadein and fadeout. with fadeout one extra value 3s.
3
Answers
In order for this work, you will need to add keyframes specifying the behaviour of fadein and fadeout for example :
Each animation is separated by a comma. The first animation is ‘fadein’ with a duration of 0.5 seconds. The second animation is ‘fadeout’ with a duration of 0.5 seconds and a delay of 3 seconds (3s).
I have made some changes to this code:
You need to define keyframes.
It is not supported by React for you to define keyframes inside the inline style object. Rather, your keyframes must be defined in a different CSS file, which your React component must then reference.
A working example you can see on my codesandbox