Thuộc tính kết xuất hình ảnh CSS
Ví dụ
Hiển thị các thuật toán khác nhau có thể được sử dụng để chia tỷ lệ hình ảnh:
.image {
height: 100px;
width: 100px;
image-rendering: auto;
}
.crisp-edges {
image-rendering: -webkit-optimize-contrast;
image-rendering: crisp-edges;
}
.pixelated {
image-rendering: pixelated;
}
.smooth {
image-rendering: smooth;
}
.high-quality {
image-rendering: high-quality;
}
Hãy tự mình thử »Định nghĩa và cách sử dụng
Thuộc tính image-rendering
chỉ định loại thuật toán được sử dụng để chia tỷ lệ hình ảnh.
Lưu ý: Thuộc tính này không có hiệu lực đối với hình ảnh không được chia tỷ lệ.
Giá trị mặc định: | tự động |
---|---|
Thừa hưởng: | Đúng |
Hoạt hình: | KHÔNG. Đọc về hoạt hình |
Phiên bản: | CSS3 |
Cú pháp JavaScript: | object .style.imageRendering="pixelated" Hãy dùng thử |
Hỗ trợ trình duyệt
Các số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ thuộc tính.
Property | |||||
---|---|---|---|---|---|
image-rendering | 41.0 | 79.0 | 65.0 | 10.0 | 28.0 |
Chrome, Edge, Opera và Safari sử dụng tên thay thế cho giá trị crisp-edges
: -webkit-optimize-contrast
.
Cú pháp CSS
image-rendering: auto|smooth|high-quality|crisp-edges|pixelated|initial|inherit;
Giá trị tài sản
Value | Description | Demo |
---|---|---|
auto | Let the browser choose the scaling algorithm. This is default | Demo ❯ |
smooth | Use an algorithm that smooth out the colors in the image | Demo ❯ |
high-quality | Same as smooth, but with a preference for higher-quality scaling | Demo ❯ |
crisp-edges | Use an algorithm that will preserve the contrast and edges in the image | Demo ❯ |
pixelated | If the image is scaled up, the nearest-neighbor algorithm is used, so the image will appear as being composed of large pixels. If the image is scaled down, it will be the same as auto | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |