Computer >> Máy Tính >  >> Lập trình >> CSS

Cách tạo bộ lọc hình ảnh bằng CSS

Bạn có thể thử chạy đoạn mã sau để tạo các bộ lọc hình ảnh như độ mờ, độ tương phản, độ sáng bằng CSS -

Ví dụ

<!DOCTYPE html>
<html>
   <head>
      <style>
         img {
            height: auto;
            float: left;
         }
         .contrast {
            -webkit-filter: contrast(180%);
            filter: contrast(180%);
         }
         .brightness {
            -webkit-filter: brightness(250%);
            filter: brightness(250%);
         }
         .blur {
            -webkit-filter: blur(4px);
            filter: blur(4px);
         }
      </style>
   </head>
   <body>
      <img
      src = "https://www.tutorialspoint.com/assets/videos/courses/19/images/course_19_image.png" alt = "Animation Training" width = "200" height = "200">

      <img class = "contrast"
         src = "https://www.tutorialspoint.com/assets/videos/courses/19/images/course_19_image.png" alt = "Animation Training" width = "200" height = "200">

      <img class = "brightness"
         src = "https://www.tutorialspoint.com/assets/videos/courses/19/images/course_19_image.png" alt = "Animation Training" width = "200" height = "200">
     
      <img class="blur"
         src = "https://www.tutorialspoint.com/assets/videos/courses/19/images/course_19_image.png alt = "Animation Training" width = "200" height = "200">
   </body>
</html>