如何使用jQuery对图像进行拖放和调整大小?

时间:2010-04-23 21:14:21

标签: jquery image drag-and-drop resizable

如何使用jQuery调整大小和图像,但保持其宽高比相同?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>CrossSlide - A jQuery plugin to create pan and cross-fade animations</title>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

</head>
<body>

<style type="text/css">
#resizebleImage { background: silver; }

</style>

<script type="text/javascript">

$(document).ready(function(){
 $("#resizebleImage").resizable().parent().draggable();  
  });
</script>

<img id="resizebleImage"  src="http://images.askmen.com/galleries/singer/gloria-estefan/pictures/gloria-estefan-picture-4.jpg">
</body>
</html>

2 个答案:

答案 0 :(得分:1)

OH ......嘿...... aspectRatio:是的,

答案 1 :(得分:1)

您可以使用'alsoResize'属性来执行此操作。

draggable.resizable({alsoResize:'#image'});
draggable.draggable();

draggable是div元素,图像嵌入div。