0

Quite a simple one but I'm sure I'm doing something wrong; the following code doesn't work in either Chrome or Firefox (ie, it displays as would be expected without the transition property, with the element immediately switching from blue to red):

.button {
  background-color: blue;
  transition: background-color, 5s, ease, 0s;
}

.button:hover {
  background-color: red;
}
<div class="button">Hello world</div>

What am I missing here?

Ruan Mendes
  • 90,375
  • 31
  • 153
  • 217
Matt Bowyer
  • 215
  • 3
  • 10
  • Does this answer your question? [Transition of background-color](https://stackoverflow.com/questions/4411306/transition-of-background-color) – Mister Jojo May 16 '22 at 16:59

2 Answers2

1

transition properties should not be separated with commas

.button {
  background-color: blue;
  transition: background-color 5s ease;
}

.button:hover {
  background-color: red;
}
<div class="button">Hello world</div>
James
  • 621
  • 7
  • 18
1

There should be no commas in transition: background-color, 5s, ease, 0s;

.button {
  background-color: blue;
  transition: background-color 5s ease 0s;
}

.button:hover {
  background-color: red;
}
<div class="button"> Hello world </div>
Ruan Mendes
  • 90,375
  • 31
  • 153
  • 217