jquery 鼠标拖拽div四个边框,可上下左右随意拉伸调节div大小

最好是有实例...先谢啦...

大家可以考虑用下面这段 是我从JQuery官网发现的

大家去网页链接下这个图片放在images文件夹里 图标要用到

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Default functionality</title>

<link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<!--属性已经拿出来了↓ <link rel="stylesheet" href="https://jqueryui.com/resources/demos/style.css"> -->
<style>
body {
    font-family: Arial, Helvetica, sans-serif;
}

table {
font-size: 1em;
}

.ui-draggable, .ui-droppable {
background-position: top;
}
</style>
<style>
#resizable { width: 150px; height: 150px; padding: 0.5em; }
#resizable h3 { text-align: center; margin: 0; }
</style>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#resizable" ).resizable();
} );
</script>
</head>
<body>
<div id="resizable" class="ui-widget-content">
<h3 class="ui-widget-header">Resizable</h3>
</div>
</body>
</html>

感谢来源于网页链接

对了 还有我楼下2012年03回答的那个兄弟 写的引用文件部分 全换成

<!-- ↓下载地址https://jqueryui.com/ -->
<!-- <link href="include/jquery-ui.css" rel="stylesheet" type="text/css" /> -->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

就可以使用了 其实和我这个一样 记得点赞评论吼

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-03-15
去看jquery ui插件,都是现成的,只要穿参就能用追问

能否具体些?麻烦你了...

追答


@import "../js/ui/css/base/jquery.ui.all.css";

缩放组件

$(document).ready(function(){
function callback(e,ui){
var content="触发"+e.type+"事件,当前大小"+ui.size.width+"*"+ui.size.height+"";
$("ol").append(content);
}
$("#resizable").resizable({
aspectRatio:true,
minHeight:50,minWidth:100,
maxHeight:150,maxWidth:300,
start:callback,
resize:callback,
stop:callback
});
});

可缩放元素
缩放时保持长宽比,并限制最大值

那几个jquery文件自己去下

追问

非常感谢,能不能让他拉动左侧边框时,向左拉伸?

本回答被提问者采纳