怎样才能让蓝色的框与红色的框缩放?(使用jQuery-UI)
这是基本的代码,CSS:
#outer {
position:relative;
height:100px;
width:150px;
z-index:1;
background:#F00;
}
#nested {
position:absolute;
left:50px; top:20px;
width:50px; height:20px;
z-index:2;
background:#00F;
cursor:pointer;
}
和HTML:
<div id="outer">
<div id="nested" onclick="$('#outer').effect('scale', {scale:'content',percent:50}, 1000);" />
</div>
发布于 2012-05-18 17:30:07
我知道这有点老了,但是如果我没理解错的话,我也在尝试实现同样的功能,并且偶然发现了这个jQuery插件:
发布于 2012-02-09 10:41:44
检查这个小提琴:http://jsfiddle.net/techfoobar/Y54EB/4/
解决方案基本上是在% w.r.t中指定嵌套div的尺寸和位置。父级而不是像素。
发布于 2012-02-09 10:42:47
将CSS更改为使用百分比:
#nested {
position:absolute;
left:30%; top:20%;
width:50%; height:20%;
z-index:2;
background:#00F;
cursor:pointer;
}
这样,#nested
div始终与outer
div成比例-也保持其位置不变
此处的工作示例-> http://jsfiddle.net/Y54EB/5/
https://stackoverflow.com/questions/9209267
复制