clip
该属性用于定义元素的哪部分是可见的。该属性只适用于绝对定位的元素。
语法
/* <shape> value */ clip: rect(2px, 2em, 5rem, 2ch); clip: auto;
值
| 值 | 描述 |
|---|---|
| shape | 此关键词表示一个矩形<shape>。<shape> = rect(<top>, <right>, <bottom>, <left>) |
| auto | 此关键词表示元素不裁剪(默认值)。 |
例子
HTML
<div id="red"> <div id="orange"></div> </div>
CSS
#red {
width: 200px;
height: 50px;
background: red;
position: relative;
}
#orange {
width: 50px;
height: 100px;
clip: rect(2px, 4em, 2em, 4ch);
background: orange;
position: absolute;
}
执行结果