clip:rect矩形剪裁
clip:rect(top right bottom left);依据上-右-下-左的顺序提供自图片左上角为(0,0)坐标计算的四个偏移数值,其中任一数值都可用auto替换.
矩形剪裁 还需要绝对定位position:absolute;这个clip有点像background-position这个属性,经常用css雪碧图都会知道。
下面就把我测试的代码方式:不能保证每张图片大小都一样,写的一个小方法,让裁切居中吧!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<style>
*{margin: 0;padding: 0;}
.a{
width: 2px;height: 300px;
background: #000;
position: absolute;z-index: 2
}
.b{
position: absolute;z-index: 3;
height: 2px;width: 600px;
background: #000;
}
</style>
<script src="jquery-1.11.1.min.js"></script>
<body>
<img id="i" src="01.jpg" alt="" width= "300 " height= "300 " style="position: absolute;top:0;left:0;">
<div class="a"></div>
<div class="b"></div>
<script>
var h=$("#i").outerHeight();
var w=$("#i").outerWidth();
var box=100;
$(".a").css("margin-left",w/2)
$(".b").css("margin-top",h/2)
var h1=(h/2)-box,
w1=(w/2)+box,
h2=(h/2)+box,
w2=(w/2)-box;
$("#i").css("clip","rect("+h1+"px,"+w1+"px,"+h2+"px,"+w2+"px)");
</script>
</body>
clip:rect矩形剪裁的更多相关文章
- CSS clip:rect矩形剪裁功能及一些应用介绍
CSS clip:rect矩形剪裁功能及一些应用介绍 by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.co ...
- CSS clip:rect矩形剪裁功能及应用
.clip{ position:absolute; clip: rect(10px 30px 20px 10px); } 最后有必要说明下:clip:rect矩形剪裁只能作用于position:abs ...
- css中clip:rect矩形剪裁功能
一.示例 img { position:absolute; clip:rect(30px,200px,200px,20px); } 二.理解 clip 属性剪裁绝对定位元素. clip:rect矩形剪 ...
- css :clip rect 正确的使用方法
CSS clip 是一个极少使用,但又确实存在的属性. 而且,它其实在CSS2时代就有了. w3school 上有这么一句话: clip 属性剪裁绝对定位元素. 也就是说,只有 position:ab ...
- clip:rect()
写进度条的时候用过这个方法,记录一下 它的用法是 .test{ clip: rect(<top>, <right>, <bottom>, <>left) ...
- OpenCV的Rect矩形类用法
转自 http://blog.csdn.net/kh1445291129/article/details/51149849 //如果创建一个Rect对象rect(100, 50, 50, 100),那 ...
- clip属性
clip:rect矩形剪裁功能及一些应用介绍. 其实是这样的,top right bottom left分别指最终剪裁可见区域的上边,右边,下边与左边.而所有的数值都表示位置,且是相对于原始元素的左上 ...
- CSS3/SVG clip-path路径剪裁遮罩属性简介
一.SVG属性和CSS3属性千丝万缕的关系 CSS3新增属性除了我们现在用的比较多的border-radius, box-shadow, gradient, ...之类,还有很重要的一个分支:SVG属 ...
- 圆环进度css
看效果先:http://sandbox.runjs.cn/show/b6bmksvn 参考: jquery圆环百分比进度条制作 CSS clip:rect矩形剪裁功能及一些应用介绍 CSS clip: ...
随机推荐
- sshfs三步走----实用(mac)
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ffffff } p.p2 { margin: 0.0px 0. ...
- IIS7.0 Appcmd 命令详解和定时重启应用池及站点的设置
IIS7.0 Appcmd 命令详解 废话不说!虽然有配置界面管理器!但是做安装包的时候命令创建是必不可少的!最近使用NSIS制作安装包仔细研究了一下Appcmd的命令,可谓是功能齐全. 上网查了些资 ...
- 绿色 或者 免安装 软件 PortableApps
Refer to http://portableapps.com/apps for detail. Below is just a list at Jan-01-2017 for quick show ...
- DBUnit的一些注意事项
DatabaseOperation.TRUNCATE_TABLE.execute(con, ds);等对数据库的操作放在每个@Test方法中做而不是在@Before里做,可增加灵活性
- mysql授权
grant all privileges on testdb to userA@'%' 然而通过userA登录查看存储过程时仍然无权限查看,通过jdbc连接程序也报错, 之前mysql在windows ...
- welcome-file-list设置问题之css,js文件无法加载
web.xml里的welcome-file-list里设置默认访问页面为/html/index.html 但是在访问时,页面CSS都没加载. 正常输入网址却没问题.用/html/index.jsp也没 ...
- React初识(按钮点击+输入绑定)
简单按钮点击事件: <!DOCTYPE html><html> <head> <meta charset="utf-8"> ...
- SPSS数据分析—广义估计方程
广义线性模型虽然很大程度上拓展了线性模型的应用范围,但是其还是有一些限制条件的,比如因变量要求独立,如果碰到重复测 量数据这种因变量不独立的情况,广义线性模型就不再适用了,此时我们需要使用的是广义估计 ...
- MacOS长按无效问题
defaults write -g ApplePressAndHoldEnabled -bool FALSE 注销并重新登录系统使其更改生效. 如果需要恢复长按键盘可以重音字符或非英文字符的功能,请打 ...
- Python【8】-分析json文件
一.本节用到的基础知识 1.逐行读取文件 for line in open('E:\Demo\python\json.txt'): print line 2.解析json字符串 Python中有一些内 ...