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

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

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

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

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

来看一个小demo吧

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小demo

新手一枚,如有错误,欢迎指正。

最新文章

  1. IOS之Objective-C学习 代理设计模式
  2. PhotoShop算法原理解析系列 - 像素化---》碎片。
  3. Linux 下多用户申请git公钥方法
  4. 10 个学习iOS开发的最佳网站(转)
  5. html5摇一摇[转]
  6. DebugViewHierarchy
  7. 11.5Daily Scrum
  8. SQLServer怎样导入excel
  9. BZOJ 1059 矩阵游戏
  10. 浅析Android中的消息机制-解决:Only the original thread that created a view hierarchy can touch its views.
  11. protobuf 系列 ---------下载、编译与使用
  12. Python 操作 MYSQL
  13. 微信小程序之canvas绘制海报分享到朋友圈
  14. ionic 打包 报错Execution failed for task &#39;:processDebugResources&#39;. &gt; com.android.ide.common.process.ProcessException: Failed to execute aapt
  15. 串口-CreateFile的使用
  16. com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
  17. NET设计模式 第二部分 结构性模式(13):代理模式(Proxy Pattern)
  18. 云端搭建内网局域网+NAT冗余上网:vps-centos6.10 +pptp client +2个ros 实现默认走pptp上网,万一pptp断了,走另外一个ros路由+centos7补充了下
  19. bind函数(c++11)
  20. 乘风破浪:LeetCode真题_037_Sudoku Solver

热门文章

  1. Thinkphp Ajax传地址
  2. Js字符串判断
  3. 微信公众平台Js API(WeixinApi)
  4. 【行为型】Strategy模式
  5. 第六周O题(等边三角形个数)
  6. Excel--java POi
  7. Mifare S50与Mifare S70
  8. 《30天自制操作系统》读书笔记(2)hello, world
  9. 转:mysql5.6.12 for Linux安装
  10. SCALA常规练习C