我环顾四周,虽然我发现了与这个问题类似的问题,但没有一个问题的解决方案对我有效。
这里有一个指向另一个类似问题的链接。Draggable and resizable in JqueryUI for an image is not working?
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
</head>
<body>
<div id="draggableHelper" style="display:inline-block">
<img id="image" src="http://www.google.com.br/images/srpr/logo3w.png" />
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#draggableHelper').draggable();
$('#image').resizable();
});
</script>
</body>
</html>这只是一个非常基本的例子,但当我运行它时,图像是可移动的,但不能调整大小。尽管据我所知,它应该是有效的。
在上面的链接中,在问题的底部有一个指向工作示例的链接。jfiddle示例使用的是带有完全相同的http://jsfiddle.net/8VY52/和javascript的jfiddle。
关于Jquery UI,我是不是遗漏了什么,为什么这可以通过Jfiddle工作,但似乎不能在上面的代码中工作。
谢谢。
发布于 2013-05-22 21:33:56
代码中缺少jquery-ui CSS文件
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css"/>演示:Plunker
发布于 2013-05-22 21:39:31
完整的工作代码将是。
</head>
<body>
<div id="draggableHelper" style="display:inline-block">
<div id="image"><img src="http://www.google.com.br/images/srpr/logo3w.png" /></div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#image').resizable();
$('#image').draggable();
$('#image').resize(function(){
$(this).find("img").css("width","100%");
$(this).find("img").css("height","100%");
});
});
</script>
</body>
</html>发布于 2013-05-22 21:33:31
这对你来说是可行的。
<div id="draggableHelper" style="display:inline-block">
<div id="image"><img src="http://www.google.com.br/images/srpr/logo3w.png" /></div>
</div> https://stackoverflow.com/questions/16692919
复制相似问题