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

Áp dụng xoay màu (Hue Rotation) cho hình ảnh bằng CSS3

Để áp dụng xoay màu cho hình ảnh với CSS3, sử dụng giá trị hue-rotate cho thuộc tính filter.

Ví dụ

<!DOCTYPE html>
<html>
<head>
<style>
img.demo {
  filter: hue-rotate(45deg);
}
</style>
</head>
<body>
<h1>Học Spring Framework</h1>
<img src="https://www.tutorialspoint.com/spring/images/spring-mini-logo.jpg" alt="Spring Framework" width="160" height="150">
<h1>Học Spring Framework</h1>
<img class="demo" src="https://www.tutorialspoint.com/spring/images/spring-mini-logo.jpg" alt="Spring Framework" width="160" height="150">
</body>
</html>

Kết quả

Áp dụng xoay màu (Hue Rotation) cho hình ảnh bằng CSS3

Giải thích:

  • hue-rotate(angle) xoay màu trên vòng tròn màu (color wheel)
  • Đơn vị: deg (độ), rad (radian), turn (vòng)
  • 0deg = không thay đổi, 360deg = quay vòng hoàn chỉnh
  • Tạo hiệu ứng thay đổi màu sắc nghệ thuật