Complete the code to add a smooth color change effect on hover.
button {
background-color: blue;
transition: background-color [1];
}
button:hover {
background-color: red;
}The transition property needs a duration like 2s to specify how long the effect takes.
Complete the code to make the transition use an ease-in timing function.
div {
width: 100px;
transition: width 1s [1];
}
div:hover {
width: 200px;
}The timing function ease-in makes the transition start slowly and speed up.
Fix the error in the transition shorthand property to smoothly change opacity over 0.5 seconds.
.box {
opacity: 0.5;
transition: [1] 0.5s ease;
}
.box:hover {
opacity: 1;
}The transition property expects the property name first, then duration and timing. Here, duration and timing are already given, so only the property name 'opacity' is needed.
Fill both blanks to create a transition that changes both background color and transform over 0.3 seconds.
.card {
transition: [1] [2];
}
.card:hover {
background-color: yellow;
transform: scale(1.1);
}The first blank lists the properties separated by commas. The second blank is the duration for the transition.
Fill all three blanks to create a transition that changes color over 1 second with an ease-out timing function.
p {
transition-property: [1];
transition-duration: [2];
transition-timing-function: [3];
}
p:hover {
color: green;
}We specify the property to transition, the duration, and the timing function separately for clarity.