Thuộc tính clip-path CSS
Thí dụ
Kẹp hình ảnh thành vòng tròn 50%:
img {
clip-path:
circle(50%);
}
Định nghĩa và Cách sử dụng
Thuộc clip-path
tính cho phép bạn cắt một phần tử thành hình dạng cơ bản hoặc với nguồn SVG.
Lưu ý: Thuộc clip-path
tính sẽ thay thế thuộc tính không dùng nữa clip
.
Giá trị mặc định: | không ai |
---|---|
Thừa hưởng: | không |
Hoạt hình: | có cho hình dạng cơ bản . Đọc về hoạt hình |
Phiên bản: | Mô-đun tạo mặt nạ CSS cấp độ 1 |
Cú pháp JavaScript: | đối tượng .style.clipPath = "circle (50%)" |
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.
Property | |||||
---|---|---|---|---|---|
clip-path | 55.0 23.0 -webkit- |
79.0* | 54.0 | 9.1 6.1 -webkit- |
42.0 15.0 -webkit- |
* Trước phiên bản 79, Edge chỉ hỗ trợ đường dẫn clip trên các phần tử SVG (không phải phần tử HTML).
Cú pháp CSS
clip: clip-source|basic-shape|margin-box|border-box|padding-box|content-box|fill-box|stroke-box|view-box|none|initial|inherit;
Giá trị tài sản
Value | Description | Play it |
---|---|---|
clip-source | Defines a URL to an SVG <clipPath> element | |
basic-shape | Clips an element to a basic shape: circle, ellipse, polygon or inset | |
margin-box | Uses the margin box as the reference box | |
border-box | Uses the border box as the reference box | |
padding-box | Uses the padding box as the reference box | |
content-box | Uses the content box as the reference box | |
fill-box | Uses the object bounding box as reference box | |
stroke-box | Uses the stroke bounding box as reference box | |
view-box | Uses the SVG viewport as reference box | |
none | This is default. No clipping is done | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |