Thuộc tính vị trí mặt nạ CSS
Thí dụ
Đặt vị trí của hình ảnh lớp mặt nạ thành trung tâm:
.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;
}
Thêm các ví dụ "Hãy tự mình thử" bên dưới.
Định nghĩa và Cách sử dụng
Thuộc mask-position
tính đặt vị trí bắt đầu của hình ảnh mặt nạ (liên quan đến khu vực 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à được 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: | object .style.maskPosition = "100px center" |
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 |
Các ví dụ khác
Thí 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%;
}
Các trang liên quan
Tham chiếu CSS: thuộc tính mask-image
Tham chiếu CSS: thuộc tính mask-mode
Tham chiếu CSS: thuộc tính mask-origin
Tham chiếu CSS: thuộc tính mask-repeat
Tham chiếu CSS: thuộc tính mask-size
Hướng dẫn CSS: CSS Masking