Hộp phong cách
Thí dụ
Thêm bóng hộp vào phần tử div:
document.getElementById("myDIV").style.boxShadow = "10px 20px 30px blue";
Định nghĩa và Cách sử dụng
Thuộc tính boxShadow đặt hoặc trả về các bóng đổ của một phần tử hộp.
Hỗ trợ trình duyệt
Property | |||||
---|---|---|---|---|---|
boxShadow | Yes | 9.0 | Yes | 5.1.1 | Yes |
Cú pháp
Trả lại hộp
object.style.boxShadow
Đặt hộp
object.style.boxShadow = "none|h-shadow v-shadow blur spread color |inset|initial|inherit"
Lưu ý: Thuộc tính boxShadow gắn một hoặc nhiều bóng đổ vào hộp. Thuộc tính là danh sách các bóng được phân tách bằng dấu phẩy, mỗi bóng được chỉ định bởi 2-4 giá trị độ dài, màu tùy chọn và từ khóa chèn tùy chọn. Độ dài bị bỏ qua là 0.
Giá trị tài sản
Value | Description |
---|---|
none | Default value. No shadow is displayed |
h-shadow | Required. The position of the horizontal shadow. Negative values are allowed |
v-shadow | Required. The position of the vertical shadow. Negative values are allowed |
blur | Optional. The blur distance |
spread | Optional. The size of shadow |
color | Optional. The color of the shadow. The default value is black. Look at CSS Color Values for a complete list of possible color values. Note: In Safari (on PC) the color parameter is required. If you do not specify the color, the shadow is not displayed at all. |
inset | Optional. Changes the shadow from an outer shadow (outset) to an inner shadow |
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: | không ai |
---|---|
Giá trị trả lại: | Một chuỗi, đại diện cho thuộc tính box-shadow của một phần tử |
Phiên bản CSS | CSS3 |
Các trang liên quan
Tham chiếu CSS: thuộc tính box-shadow
❮ Đối tượng phong cách