Thuộc tính vị trí mặt nạ CSS
Ví dụ
Đặt vị trí của hình ảnh lớp mặt nạ ở giữa:
.mask1 {
-webkit-mask-image: url(w3logo.png);
mask-image: url(w3logo.png);
-webkit-mask-size: 50%;
mask-size: 50%;
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
-webkit-mask-position: center;
mask-position: center;
}
Hãy tự mình thử »Thêm ví dụ "Hãy tự mình thử" bên dưới.
Định nghĩa và cách sử dụng
Thuộc tính mask-position
đặt vị trí bắt đầu của hình ảnh mặt nạ (so với vùng vị trí mặt nạ).
Mẹo: Theo mặc định, hình ảnh mặt nạ được đặt ở góc trên cùng bên trái của một phần tử và lặp lại theo cả chiều dọc và chiều ngang.
Giá trị mặc định: | 0% 0% |
---|---|
Thừa hưởng: | KHÔNG |
Hoạt hình: | KHÔNG. Đọc về hoạt hình |
Phiên bản: | CSS3 |
Cú pháp JavaScript: | đối tượng .style.maskPosition="Trung tâm 100px" |
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.
Các số theo sau -webkit- chỉ định phiên bản đầu tiên hoạt động với tiền tố.
Property | |||||
---|---|---|---|---|---|
mask-position | 4.0 -webkit- | 79.0 -webkit- | 53.0 | 4.0 -webkit- | 15.0 -webkit- |
Cú pháp CSS
mask-position: value ;
Giá trị tài sản
Value | Description |
---|---|
left top left center left bottom right top right center right bottom center top center center center bottom |
If you only specify one keyword, the other value will be "center" |
x% y% | The first value is the horizontal position and the second value is the vertical. The top left corner is 0% 0%. The right bottom corner is 100% 100%. If you only specify one value, the other value will be 50%. Default value is: 0% 0% |
xpos ypos | The first value is the horizontal position and the second value is the vertical. The top left corner is 0 0. Units can be pixels (0px 0px) or any other CSS units . If you only specify one value, the other value will be 50%. You can mix % and positions |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Thêm ví dụ
Ví dụ
Đặt vị trí của hình ảnh lớp mặt nạ ở góc dưới bên phải:
.mask1 {
-webkit-mask-image: url(w3logo.png);
mask-image: url(w3logo.png);
-webkit-mask-size: 50%;
mask-size: 50%;
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
-webkit-mask-position: 100% 100%;
mask-position: 100% 100%;
}
Hãy tự mình thử »Trang liên quan
Tham chiếu CSS: thuộc tính hình ảnh mặt nạ
Tham chiếu CSS: thuộc tính chế độ mặt nạ
Tham chiếu CSS: thuộc tính mặt nạ gốc
Tham chiếu CSS: thuộc tính lặp lại mặt nạ
Tham chiếu CSS: thuộc tính kích thước mặt nạ
Hướng dẫn CSS: Mặt nạ CSS