Javascript Jquery Resizeable()显示调整大小图标但不调整大小
我有一个带有两个可调整大小的Javascript Jquery Resizeable()显示调整大小图标但不调整大小,javascript,jquery,html,jquery-ui,jquery-ui-resizable,Javascript,Jquery,Html,Jquery Ui,Jquery Ui Resizable,我有一个带有两个可调整大小的divs的页面。第一个可以正常工作,第二个显示调整大小图标,但没有调整大小 这是我的html: <html> <head> <link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="css/jquery-ui-1.10.4.css"> <script src="js/jquery
div
s的页面。第一个可以正常工作,第二个显示调整大小图标,但没有调整大小
这是我的html:
<html>
<head>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="css/jquery-ui-1.10.4.css">
<script src="js/jquery-1.10.2.js"></script>
<script src="js/jquery-ui-1.10.4.js"></script>
</head>
<body>
<div id="page">
<img id="img_site_top" src="site_top.png">
<div id="img_header" style="position: absolute; left: 7px; top: 7px; background-image: url(header.png); width:980px; height:106px;">
<a id="img_logo" class="jqDrag" style="position:absolute; top: -11px; left: 0px; width:350px; height:107px; background-image: url(logo.png); background-size: 100% 100%;background-repeat: no-repeat; border: 1px solid white">
</a>
</div>
<img id="img_site" src="site.png">
<img id="img_welcome_panel" src="welcome_panel.png">
</div>
</body>
<script>
$(
function(){
$('#img_logo').draggable().resizable({ aspectRatio: true }); //works
$('#img_header').resizable(); //doesn't work: shows the icon, but doesn't resize.
}
);
</script>
</html>
我错过了什么?为什么第一个框可以工作而第二个框不能工作?这可能是因为绝对定位的缘故,只需将其更改为仅设置
位置:相对代码>尝试更改初始化顺序。演示:。
替换此项:
$(function(){
$('#img_logo').draggable().resizable({ aspectRatio: true }); //works
$('#img_header').resizable(); //doesn't work: shows the icon, but doesn't resize.
});
与:
$(function(){
$('#img_header').resizable();
$('#img_logo').draggable().resizable({ aspectRatio: true });
});
这不可能是问题所在$(“#img_logo”)
也绝对定位,并且调整大小不会出现问题。不管怎样,只要试一下,那不是问题。嘿!真管用!你能解释一下为什么订单很重要吗?我对此一无所知。我认为这是jQuery的错误。您可以在此处找到更多:。我认为只有当我们有嵌套的可调整大小的元素时,顺序才是重要的,否则顺序并不重要。无论如何,如果这对你有效,你可以把它标记为答案。谢谢!我将记住这一点,以便将来使用可调整大小的函数:)