Transition in CSS
In CSS, transitions provide a way to smoothly animate changes in CSS properties. They allow elements to change from one style to another over a specified duration, creating a more dynamic and visually appealing user experience. By defining which CSS properties to transition and the duration of the transition, developers can add subtle animations that enhance usability and engagement.
Here are some examples of transition
In this example, '.box' div appears as a blue square with dimensions 100px by 100px. When hovering over the '.box' div, the width and height increase to 200px smoothly over 0.5s. Simultaneously, the background-color transitions from blue to tomato over 0.5s, creating a smooth color change effect.
OUTPUT :
In this example, HTML code defines a button styled using CSS. The button has padding, green background, white text, no border, and changes color on hover. CSS `.btn` class styles the button, and `:hover` pseudo-class changes background to dark green and text to light gray.
In conclusion, CSS transition enables smooth property changes over time, enhancing user experience. It specifies the duration, timing function, property, and delay of transitions, allowing elements to animate from one state to another gracefully. This capability is crucial for creating interactive and visually appealing interfaces, where elements can smoothly transform in response to user actions like hover or click events.