The button hover effect works reversely

Welcome to our community

Be apart of something great, join today!

Antoniovnp

Newbie
Messages
6
Reaction score
1
Points
3
Hello,

When I mouse over the button, the transition effect only works after leaving it.

CSS:
button {
    width: 100%;
    margin: 0 auto;
    border: none;
    border-radius: 8rem;
    background: $neutral-darkGrayBlue;
    color: $neutral-white;
    padding: 1rem;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: 1s ease-in;

    &:hover {
      background: linear-gradient(
        $gradient-bg-lightSlateBlue,
        $gradient-bg-lightRoyalBlue
      );
    }
  }

Can anyone help me, please?
 
Solution
You can't transition to/from a gradient.

When you leave, the background is the light gray default of the button (cause it instantly turns off the gradient), and that transitions to your dark color background is a shorthand.

You have background-color and background-image, and we can't transition between two different properties (also, background-image can't can't be animated/transitioned, so that means gradients can't be.)

annpef

Newbie
Messages
4
Reaction score
0
Points
1
You can't transition to/from a gradient.

When you leave, the background is the light gray default of the button (cause it instantly turns off the gradient), and that transitions to your dark color background is a shorthand.

You have background-color and background-image, and we can't transition between two different properties (also, background-image can't can't be animated/transitioned, so that means gradients can't be.)
 
Solution
  • Advertisement
  • Advertisement

    Top