css clip 属性 用来设置元素的形状。用来剪裁绝对定位元素。当一幅图像的尺寸大于包含它的元素时,"clip" 属性允许规定一个元素的可见尺寸,这样此元素就会被修剪并显示在这个元素中。
使用css clip属性需要注意以下三点:
1.clip属性只能用于绝对定位元素,position:absolute或fixed。
2.clip属性有三种取值:auto 默认的;inherit继承父级的;一个定义好的形状,但现在只能是方形的 rect(),clip: { shape | auto | inherit }
3.shape rect(<top>, <right>, <bottom>, <left>)中的四个元素不可省略。
实例
<!doctype html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<title>clip</title>
<style type="text/css">
img {
position:absolute;
top:0;
left:10px;
clip: rect(52px, 280px, 290px, 95px);
}
</style>
</head>
<body>
<img src="00.jpg"/>
</body>
</html>原图和页面显示图片如下:
原图
页面显示图
以上就是css clip属性怎么用的详细内容,更多请关注Gxlcms其它相关文章!
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did68677