clip CSS property defines a visible portion of an element. The clip property applies only to absolutely positioned elements — that is, elements with position:absolute or position:fixed .

/* Keyword value */
clip: auto;
/* <shape> values */
clip: rect(1px, 10em, 3rem, 2ch);
/* Global values */
clip: inherit;
clip: initial;
clip: unset;
					

句法

注意: Where possible, authors are encouraged to use the newer clip-path 特性代替。

<<shape>()>
A rectangular <<shape>()> of the form rect(<top>, <right>, <bottom>, <left>) <top> and <bottom> values are offsets from the inside top border edge of the box, while <right> and <left> are offsets from the inside left border edge of the box — that is, the extent of the padding box.
<top> , <right> , <bottom> ,和 <left> values may be either a <length> or auto . If any side's value is auto , the element is clipped to that side's inside border edge .
auto
The element does not clip (default). This is different from rect(auto, auto, auto, auto) , which clips to the element’s inside border edges.

形式定义

初始值 auto
适用于 absolutely positioned elements
继承 no
计算值 auto if specified as auto , otherwise a rectangle with four values, each of which is auto if specified as auto or the computed length otherwise
动画类型 a rectangle

形式句法

<shape> | auto

where
<shape> = rect(<top>, <right>, <bottom>, <left>)

范例

Clipping an image

CSS

.dotted-border {
  border: dotted;
  position: relative;
  width: 536px;
  height: 350px;
}
#top-left,
#middle,
#bottom-right {
  position: absolute;
  top: 0;
}
#top-left {
  left: 360px;
  clip: rect(0, 175px, 113px, 0);
}
#middle {
  left: 280px;
  clip: rect(119px, 255px, 229px, 80px);
}
#bottom-right {
  left: 200px;
  clip: rect(235px, 335px, 345px, 160px);
}
					

HTML

<p class="dotted-border">
  <img src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Original graphic">
  <img id="top-left" src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Graphic clipped to upper left">
  <img id="middle" src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Graphic clipped towards middle">
  <img id="bottom-right" src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Graphic clipped to bottom right">
</p>
					

结果

规范

规范 状态 注释
CSS Masking Module Level 1
The definition of 'clip' in that specification.
候选推荐 Deprecates clip property, suggests clip-path as replacement.
CSS Level 2 (Revision 1)
The definition of 'clip' in that specification.
推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
clip 弃用 Chrome 完整支持 1 Edge 完整支持 12 Firefox 完整支持 1 IE 完整支持 4 注意事项
完整支持 4 注意事项
注意事项 Before Internet Explorer 7, Internet Explorer incorrectly interprets clip: auto as clip: rect(auto, auto, auto, auto) .
Opera 完整支持 7 Safari 完整支持 1 注意事项
完整支持 1 注意事项
注意事项 Safari incorrectly interprets clip: auto as clip: rect(auto, auto, auto, auto) .
WebView Android 完整支持 37 Chrome Android 完整支持 18 Firefox Android 完整支持 4 Opera Android 完整支持 14 Safari iOS 完整支持 1 注意事项
完整支持 1 注意事项
注意事项 Safari incorrectly interprets clip: auto as clip: rect(auto, auto, auto, auto) .
Samsung Internet Android 完整支持 1.0

图例

完整支持

完整支持

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

见实现注意事项。

另请参阅

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考
  3. CSS Masking
  4. 特性
    1. clip
    2. clip-path
    3. mask
    4. mask-border
    5. mask-border-mode
    6. mask-border-outset
    7. mask-border-repeat
    8. mask-border-slice
    9. mask-border-source
    10. mask-border-width
    11. mask-clip
    12. mask-composite
    13. mask-image
    14. mask-mode
    15. mask-origin
    16. mask-position
    17. mask-repeat
    18. mask-size
    19. mask-type

Copyright  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1