Ask any question about CSS here... and get an instant response.
Post this Question & Answer:
How can I use CSS to create a smooth hover transition effect on buttons?
Asked on Apr 25, 2026
Answer
To create a smooth hover transition effect on buttons using CSS, you can utilize the `transition` property. This property allows you to define the duration and type of transition for specific CSS properties when they change, such as when a user hovers over a button.
<!-- BEGIN COPY / PASTE -->
<style>
.button {
background-color: #008CBA;
color: white;
padding: 10px 20px;
border: none;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.3s ease;
}
.button:hover {
background-color: #005f73;
transform: scale(1.05);
}
</style>
<button class="button">Hover Me</button>
<!-- END COPY / PASTE -->Additional Comment:
- The `transition` property specifies which CSS properties will transition, the duration, and the timing function.
- In this example, both `background-color` and `transform` properties will transition over 0.3 seconds with an `ease` timing function.
- The `transform: scale(1.05)` enlarges the button slightly on hover, enhancing the visual effect.
- Ensure the button has a `cursor: pointer` to indicate interactivity.
Recommended Links:
