css中clip裁剪怎么用

发布时间:2021-08-30 14:28:55 作者:小新
来源:亿速云 阅读:133

这篇文章给大家分享的是有关css中clip裁剪怎么用的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

clip 属性是用来设置元素的形状。用来剪裁绝对定位元素(absolute or fixed)。

clip有三种取值:auto |inherit|rect。inherit是继承,ie不支持这个属性, auto是默认  前两个基本属于打酱油的,我们主要来说一下clip的rect属性。

clip的rect属性 : clip:rect(top,right,bottom,left)四个属性值不可缺少;

这四个属性值到底是如何计算的呢 先看下边这张图

 css中clip裁剪怎么用

rect的top,right,bottom,left是基于左上角来计算的

html:

<div id="demo">  
    <u class="c1"></u><u class="c2"></u>  
 </div>

css:

#demo { position: relative; border: 1px solid #ccc; width:140px; height: 140px; padding-top: 20px; }   
 #demo u { width: 128px;height: 128px; position: absolute; background: url(words.png) 0 -624px no-repeat;transition: all .5s ease-in-out 0s}   
 #demo p { text-align: center; line-height: 120px; background: url(words.png) 400px -624px no-repeat}   
 #demo .c1 { clip: rect(0,128px,0,64px);}   
 #demo .c2 { clip:rect(128px,64px,128px,0px)}   
 #demo:hover>.c1 {clip:rect(0px,128px,128px,64px)}   
 #demo:hover>.c2 {clip:rect(0px,64px,128px,0)}

感谢各位的阅读!关于“css中clip裁剪怎么用”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

推荐阅读:
  1. canvas中如何使用clip()函数裁剪
  2. css中如何应用clip属性

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

css clip

上一篇:MySQL中的使用技巧有哪些

下一篇:java编程语言有什么优势

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》