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?

Juan Mendes
  • 85,853
  • 29
  • 146
  • 204
Matt Bowyer
  • 195
  • 1
  • 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
  • 623
  • 7
  • 17
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>
Juan Mendes
  • 85,853
  • 29
  • 146
  • 204