Dev Helpers
← Back

Transition only text and background colours

Transition only text and background colours with native CSS. The preview includes a small shared demo stylesheet.

Open this example in the interactive library

Source code

<style>
  .demo {
    transition:
      color 0.3s,
      background-color 0.3s;
  }
  .demo:hover {
    color: white;
    background-color: #134e4a;
  }
</style>
<button class="demo" type="button">Try this button</button>