Thuộc tính độ mờ kiểu
Ví dụ
Làm cho phần tử DIV trở nên trong suốt:
document.getElementById("myDIV").style.opacity = "0.5";
Hãy tự mình thử »Sự miêu tả
Thuộc tính độ mờ đặt hoặc trả về mức độ mờ của một phần tử.
Mức độ mờ của một phần tử mô tả mức độ trong suốt, trong đó 1 hoàn toàn không xuyên thấu, 0,5 là khả năng nhìn xuyên qua 50% và 0 là hoàn toàn trong suốt.
Hỗ trợ trình duyệt
Property | |||||
---|---|---|---|---|---|
opacity | Yes | Yes | Yes | Yes | Yes |
Cú pháp
Trả về thuộc tính độ mờ:
object .style.opacity
Đặt thuộc tính độ mờ:
object .style.opacity = "number |initial|inherit"
Giá trị tài sản
Value | Description |
---|---|
number | Specifies the opacity. From 0.0 (fully transparent) to 1.0 (fully opaque) |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Chi tiết kỹ thuật
Giá trị mặc định: | 1 |
---|---|
Giá trị trả về: | Một Chuỗi, biểu thị mức độ mờ của một phần tử |
Phiên bản CSS | CSS3 |
Trang liên quan
Tham chiếu CSS: thuộc tính độ mờ