值 | 描述 |
shape | 设置元素的形状。唯一合法的形状值是:rect (top, right, bottom, left) |
auto | 默认值。不应用任何剪裁。 |
inherit | 规定应该从父元素继承 clip 属性的值。 |
<html>
<head>
<style type="text/css">
img
{
position:absolute;
clip:rect(0px 50px 200px 0px)
}
</style>
</head>
<body>
<p>clip 属性剪切了一幅图像:</p>
<p><img border="0" src="/i/eg_bookasp.gif" width="120" height="151"></p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>div{
width: 190px;
height: 190px;
background: aqua;
position: relative;
}
div:before,
div::after
{
position: absolute;
content: "";
left: -5px;
right: -5px;
top: -5px;
bottom: -5px;
border: 5px solid #ff00ff88;
}
div:before{
animation: move 2s linear infinite alternate;
}
div:after{
/* alternate 动画应该轮流反向播放: */
border-color: #ff000088;
animation: move 2s linear infinite alternate -1.5s;
}
@keyframes move{
/* css -clip属性,让你指定一个绝对定位的元素,该尺寸应该是可见的,该元素被剪裁成这种形状并显示。 */
/* 设置元素的形状。唯一合法的形状值是rect (top, right, bottom, left) */
0%,100%{
clip: rect(0,200px,5px,0);
}
25%{
border-color: blue;
clip: rect(0,200px,200px,195px);
}
50%{
border-color: green;
clip: rect(195px,200px,200px,0);
}
75%{
border-color: yellow;
clip: rect(0,5px,200px,0px);
}
}
</style>
</head>
<body>
<div>传智播客</div>
</body>
</html>
| 欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |