In this article we are going to learn about Transition shorthand with multiple properties in CSS, The transition shorthand in CSS allows specifying multiple properties for smooth transitions between different states or values. The transition property in CSS is used to create some transition in an element. This property changes the value smoothly. This article contains a hover effect over a div element to change the width and height of elements after the transition.
The list of transition properties is given below:
- transition-property
- transition-duration
- transition-timing-function
- transition-delay
Syntax:
div {
transition: <property> <duration> <timing-function> <delay>;
}
Example 1: In this example, we are using the above-explained properties.
html
<!DOCTYPE html>
< html >
< head >
< style >
h1 {
color: Green;
text-align: center;
}
h3 {
text-align: center;
}
input[type=text] {
width: 100px;
-webkit-transition: width .35s ease-in-out;
transition: width .35s ease-in-out;
}
input[type=text]:focus {
width: 250px;
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< h3 >Search:
< input type = "text"
name = "searchbox" >
</ h3 >
</ body >
</ html >
|
Output:

Note: If the duration part is not specified, the transition will have no effect, because its default value is 0. The transition property specifies mainly two things. The first one is the CSS property to add effects and the second one is the duration unless the transition will be effect less.
Example 2: Here is another example of transition property.
html
<!DOCTYPE html>
< html >
< head >
< style >
h1 {
color: Green;
}
div {
width: 1px;
height: 0px;
text-align: center;
background: Green;
-webkit-transition: width 2s, height 2s;
transition: width 2s, height 2s;
}
div:hover {
width: 300px;
height: 240px;
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< div >
< img src =
align = "middle" >
</ div >
</ body >
</ html >
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
03 Aug, 2023
Like Article
Save Article