A smooth colour change

Make a colour change smooth.

What to build

A transition on a button.

Requirements

  • .button has a background of teal.
  • .button has a transition of background-color over 0.2s.
  • .button:hover has a background of navy.

Constraints

Do not write transition: all.

Example

transition: color 0.3s ease;

Why it works

With the transition on the normal state, the browser smooths the change in both directions.

Hints

Hint 1

The transition belongs on .button, not on the hover rule.

Solution

Show one correct solution (try it yourself first)
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Transition</title>
  <style>
    .button {
      background: teal;
      transition: background-color 0.2s ease;
    }
    .button:hover { background: navy; }
  </style>
</head>
<body>
  <button class="button">Press</button>
</body>
</html>

Lesson: Transitions, transforms and animations →