【发布时间】:2014-07-12 13:09:27
【问题描述】:
我正在尝试缩放一个元素并拖动该元素以创建一个可以在所有屏幕分辨率下工作的 WorkSpace。
我遇到的问题是我做不到。如果您尝试使用 Fiddle Code,您会看到正在调整大小的元素不会到达最后一个角落。我读过很多这样的帖子 (jQuery Drag/Resize with CSS Transform Scale),但问题是当你引用一个容器时。
带有错误示例的小提琴代码:
更新:也添加了文字
HTML
<div id="containerDragable">
<img id="img_messi" style="display: inline; position: absolute; z-index: 101; " src="http://www.elconfidencial.com/fotos/noticias_2011/2012090245messi_dentro.jpg" />
<div id="text_example">hi!</div>
CSS
#containerDragable {
width: 80vw;
height: 45vw;
background-color: rgb(227, 227, 227);
margin: auto;
top: 0;
bottom: 0;
left: 0;
right: 0;
position:absolute;
}
#img_messi
{
-webkit-transform-origin: 0 0;
-moz-transform-origin: 0 0;
-ms-transform-origin: 0 0;
-o-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: scale(0.5);
position:absolute;
}
#text_example
{
font: normal 36px arial,sans-serif;
position:absolute;
-webkit-transform-origin: 0 0;
-moz-transform-origin: 0 0;
-ms-transform-origin: 0 0;
-o-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: scale(0.5);
}
JavaScript
$(function () {
$('#img_messi').draggable({
containment: "#containerDragable", cursor: "move", scroll: false
});
});
$(function () {
$('#text_example').draggable({
containment: "#containerDragable", cursor: "move", scroll: false
});
});
谢谢!!
【问题讨论】:
标签: javascript jquery html css jquery-ui