Saturday , February 22 2025

Transition – smooth effects

A sharp change in the background when hovering over the block, or a sharp change in the color of the button text when hovering, without effects does not look cool. To make a smooth “fade”, you need to use one property for the main element, and for its :hover. Code Examples:

Transition to change the background

.block {transition: background 0.5s ease;}
.block:hover {transition: background 0.5s ease;}

If you need to change the font color at the same time as changing the background, but faster, then use the example:

.block {transition: background 0.5s ease, color 0.3s ease;}
.block:hover {transition: background 0.5s ease, color 0.3s ease;}

Changing the block size via transition

.block { transition: background-size 0.5s ease;}
.block:hover {width: 50px; height: 50px;}

About iryna

I'm Iryna, a web developer from Ukraine with a decade of experience solving complex technical challenges in the world of freelance. Throughout my career, I've worked on everything from troubleshooting server-side issues and optimizing website performance to enhancing user interfaces. On this blog, I share detailed solutions to the technical problems I’ve encountered and methods that have worked best for me. In addition to my technical expertise, I’m also passionate about digital drawing. I hope the tutorials and insights I provide here will help both fellow developers and creatives alike in their own projects.

Check Also

Css styles for WordPress admin in functions.php

If you need to add individual styles, and they are only a couple of lines, …

Leave a Reply

Your email address will not be published. Required fields are marked *