Свойство CSS clip-path
Пример
Обрежьте изображение до круга 50%:
img {
clip-path:
circle(50%);
}
Определение и использование
Свойство clip-path
позволяет обрезать элемент по базовой форме или по источнику SVG.
Примечание. Это clip-path
свойство заменит устаревшее clip
свойство.
Значение по умолчанию: | никто |
---|---|
Унаследовано: | нет |
Анимация: | да для базовой формы . Читать об анимации |
Версия: | Модуль маскировки CSS, уровень 1 |
Синтаксис JavaScript: | объект .style.clipPath="круг(50%)" |
Поддержка браузера
Цифры в таблице указывают на первую версию браузера, которая полностью поддерживает это свойство.
Property | |||||
---|---|---|---|---|---|
clip-path | 55.0 23.0 -webkit- |
79.0* | 54.0 | 9.1 6.1 -webkit- |
42.0 15.0 -webkit- |
* До версии 79 Edge поддерживал clip-path только для элементов SVG (но не элементов HTML).
Синтаксис CSS
clip: clip-source|basic-shape|margin-box|border-box|padding-box|content-box|fill-box|stroke-box|view-box|none|initial|inherit;
Значения свойств
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 |