คุณสมบัติการแสดงผลภาพ CSS
ตัวอย่าง
แสดงอัลกอริธึมต่างๆ ที่สามารถใช้ในการปรับขนาดภาพได้:
.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;
}
ความหมายและการใช้งาน
คุณสมบัติimage-rendering
ระบุประเภทของอัลกอริทึมที่จะใช้สำหรับการปรับขนาดภาพ
หมายเหตุ:คุณสมบัตินี้ไม่มีผลกับรูปภาพที่ไม่ได้ปรับขนาด
ค่าเริ่มต้น: | รถยนต์ |
---|---|
รับการถ่ายทอด: | ใช่ |
เคลื่อนไหวได้: | ไม่. อ่านเกี่ยวกับแอนิเมชั่น |
รุ่น: | CSS3 |
ไวยากรณ์ JJavaScript: | วัตถุ .style.imageRendering="pixelated" |
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
Property | |||||
---|---|---|---|---|---|
image-rendering | 41.0 | 79.0 | 65.0 | 10.0 | 28.0 |
Chrome, Edge, Opera และ Safari ใช้ชื่ออื่นสำหรับค่า
crisp-edges
:-webkit-optimize-contrast
ไวยากรณ์ CSS
image-rendering: auto|smooth|high-quality|crisp-edges|pixelated|initial|inherit;
มูลค่าทรัพย์สิน
Value | Description |
---|---|
auto | Let the browser choose the scaling algorithm. This is default |
smooth | Use an algorithm that smooth out the colors in the image |
high-quality | Same as smooth, but with a preference for higher-quality scaling |
crisp-edges | Use an algorithm that will preserve the contrast and edges in the image |
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 |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |