Computer >> Computer tutorials >  >> Programming >> CSS

The CSS scale() Function


The scale() function in CSS is used to define a transformation that resizes an element on the 2D plane. Set the amount of scaling in each direction as the parameter of the scale() function.

Example

<!DOCTYPE html>
<html>
<head>
<style>
.translate_img {
   transform: translate(100px, 10%);
}
.scale_img {
   transform: scale(1.2);
   background-color: yellow;
}
</style>
</head>
<body>
<h1>Learn</h1>
<img class="translate_img" src=
"https://www.tutorialspoint.com/videotutorials/assets/videos/courses/509/images/course_509_image.png"
alt="MongoDB">
<img class="scale_img" src=
"https://www.tutorialspoint.com/videotutorials/assets/videos/courses/509/images/course_509_image.png"
alt="MongoDB">
</body>
</html>

Output

The CSS scale() Function

Example

Let us now see another example −

<!DOCTYPE html>
<html>
<head>
<style>
.translate_img {
   transform: translate(100px, 10%);
}
.scale_img {
   transform: scale(0.3);
}
</style>
</head>
<body>
<h1>Learn</h1>
<img class="translate_img" src=
"https://www.tutorialspoint.com/videotutorials/assets/videos/courses/509/images/course_509_image.png"
alt="MongoDB">
<img class="scale_img" src=
"https://www.tutorialspoint.com/videotutorials/assets/videos/courses/509/images/course_509_image.png"
alt="MongoDB">
</body>
</html>

Output

The CSS scale() Function