clip
已废弃: 该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。
概述
clip
属性定义了元素的哪一部分是可见的。clip
属性只适用于 position:absolute
的元素。
警告:这个属性已被废弃。建议使用 clip-path
。
语法
值
<shape>
- 一个矩形
<shape>
(en-US)rect(<top>, <right>, <bottom>, <left>) /* 标准语法 */
或rect(<top> <right> <bottom> <left>) /* 向后兼容语法 */
<top>
和<bottom>
指定相对于盒子上边框边界 的偏移,<right>
和<left>
指定了相对于盒子左边框边界 的偏移。 <top>
,<right>
,<bottom>
, 和<left>
的值可以是<length>
值或auto
。auto
- 元素不裁剪(默认值)
示例
p { border:dotted; position:relative; }
#img2 {
position:absolute; left:263px;
clip: rect(40px, 200px, 150px, 30px);
/* 标准语法,Internet Explorer 4-7 不支持 */
}
#img3 {
position: absolute; left:526px;
clip: rect(40px 200px 150px 30px);
/* 非标准语法,但是包括火狐与 IE 在内的主要浏览器均支持 */
}
规范
Specification | Status | Comment |
---|---|---|
CSS Transitions clip |
Working Draft | Defines clip as animatable. |
CSS Level 2 (Revision 1) clip |
Recommendation |
浏览器兼容性
BCD tables only load in the browser
See also
- Related CSS properties:
text-overflow
,white-space
,overflow-x
,overflow-y
,overflow
,display
,position