CSS inset() Function

Hàm inset() là một hàm dựng sẵn trong CSS. Nó được dùng với thuộc tính filter để thay đổi inset của ảnh.

Cú pháp: 

inset( length | percentage );

Tham số: Hàm này nhận một tham số là length. Tham số này dùng để giữ giá trị của mức tương phản áp dụng cho ảnh. Đối số có thể là giá trị phần trăm hoặc độ dài. Đây là một tham số bắt buộc.

Ví dụ: Trong ví dụ này, chúng ta sẽ sử dụng hàm inset().

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS inset() function
    </title>

    <style>
        div {
            float: left;
            width: 185px;
            height: 185px;
            shape-outside: inset(20%);
        }

        img {
            width: 145px;
            height: 150px;
        }

        h1,
        h4 {
            text-align: center;
        }

        h1 {
            color: green;
        }

        .clr {
            color: white;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <h4>CSS | inset() function</h4>
    <div>
        <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190807114330/GFG115.png" 
             alt="Sample image">
    </div>

    <p>
          How many times- were you frustrated while looking out for a
        good collection of programming/algorithm/interview questions?
        What did you expect and what did you get? This portal has been
        created to provide well written, well thought and well explained
        solutions for selected questions. An IIT Roorkee alumnus and
        founder of GeeksforGeeks. He loves to solve programming problems
        in most efficient ways. Apart from GeeksforGeeks, he has worked
        with DE Shaw and Co. as a software developer and JIIT Noida as
        an assistant professor.It is a good platform to learn programming.
        It is an educational website. Prepare for the Recruitment drive
        of product based companies like Microsoft, Amazon, Adobe etc with
        a free online placement preparation course.
    </p>

</body>

</html>

Kết quả: 

css-inset-function

Trình duyệt được hỗ trợ: Các trình duyệt được CSS inset() Function hỗ trợ được liệt kê dưới đây:  

  • Google Chrome 37 trở lên
  • Microsoft Edge 79 trở lên
  • Internet Explorer không được hỗ trợ
  • Mozilla Firefox 54 trở lên
  • Safari 10.1 trở lên
  • Opera 24 trở lên

Last Updated : 21/07/2025