HTML-CSS: Zoom in zoom out animation
HTML-CSS : Exercise-45 with Solution
Using HTML, CSS creates a zoom in zoom out animation.
- Use @keyframes to define a three-step animation. At the start (0%) and end (100%), the element is its original size (scale(1 ,1)). Halfway through (50%) it's scaled up to 1.5 times its original size (scale(1.5, 1.5)).
- Use width and height to give the element a specific size.
- Use animation to set the appropriate values for the element to make it animated.
HTML Code:
<!--License: https://bit.ly/3GjrtVF-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Using HTML, CSS creates a zoom in zoom out animation</title>
</head>
<body>
<div class="zoom-in-out-box">w3r</div>
</body>
</html>
CSS Code:
.zoom-in-out-box {
margin: 24px;
width: 50px;
height: 50px;
background: #f500cc;
animation: zoom-in-zoom-out 1s ease infinite;
}
@keyframes zoom-in-zoom-out {
0% {
transform: scale(1, 1);
}
50% {
transform: scale(1.5, 1.5);
}
100% {
transform: scale(1, 1);
}
}
HTML-CSS Editor:
See the Pen html-css-practical-exercises by w3resource (@w3resource) on CodePen.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
HTML-CSS: Tips of the Day
How to get CSS to select ID that begins with a string ?
[id^=product]
^= indicates "starts with". Conversely, $= indicates "ends with".
The symbols are actually borrowed from Regex syntax, where ^ and $ mean "start of string" and "end of string" respectively.
Ref: https://bit.ly/3rSZ2t7
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework