javascriptcssreactjsonhover

Add the on hover animation in the “sign up” with React


I would like add the on hover animation in the “sign up”. I'm searching everywhere how do it but can't find anything.

<div onClick={() => toggleRegister("login")}>Sign In</div>

Solution

  • You can use the CSS :hover pseudo-selector:

    .sign-up-element {
        background-color: #f00;
        transition: background-color .3s; /* The transition property sets an animation to a specified attribute or "all" */
    }
    
    .sign-up-element:hover {
        background-color: #00f;
    }
    

    This approach works with any page that uses CSS.