Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> CSS

Hàm CSS scale() - Phóng to/Thu nhỏ phần tử


Hàm scale() trong CSS dùng để định nghĩa phép biến đổi thay đổi kích thước phần tử trên mặt phẳng 2D. Đặt lượng phóng to/thu nhỏ theo mỗi hướng làm tham số của scale().

Ví dụ

<!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>

Kết quả

Hàm CSS scale() - Phóng to/Thu nhỏ phần tử

Ví dụ khác

<!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>

Kết quả

Hàm CSS scale() - Phóng to/Thu nhỏ phần tử