views:

150

answers:

1

I have a problem with the jquery resizable plugin. I have troubleshot the issue and have come up with this. If I create a div and make it resizable and make it also have an alsoResize it works fine for the most part. However, If I set the second div that is alsoResize to margin:0 auto it does not work properly. The mouse cursor is coming off the part where you resize it. So here is an example of what i am talking about:

<div id="container">
  <div id="inside" style="margin:0 auto;">
  </div>
</div>

The jquery:

$("#container").resizable({ alsoResize:"#inside" });

If I take out the auto in the margin it works fine but with it in there it isnt working. Is there a way to make this work or just another way to center the page without using auto?

A: 

I grabbed the code of one of the demos for the Resizeable plugin and tweaked it to do what I think you're trying to accomplish. If this isn't it, please provide a link to what you have, or paste in the entire page:

<!doctype html>
<html lang="en">
<head>
 <title>jQuery UI Resizable - Default functionality</title>
 <link type="text/css" href="http://jqueryui.com/themes/base/ui.all.css" rel="stylesheet" />
 <script type="text/javascript" src="http://jqueryui.com/jquery-1.3.2.js"&gt;&lt;/script&gt;
 <script type="text/javascript" src="http://jqueryui.com/ui/ui.core.js"&gt;&lt;/script&gt;
 <script type="text/javascript" src="http://jqueryui.com/ui/ui.resizable.js"&gt;&lt;/script&gt;

 <link type="text/css" href="http://jqueryui.com/demos/demos.css" rel="stylesheet" />
 <style type="text/css">
  #container { width: 150px; height: 150px; }
  #container #inside { height:100px; width:100px; margin:0 auto; background:#eee; }
 </style>
 <script type="text/javascript">
 $(function() {
  $("#container").resizable({ alsoResize:"#inside" });
 });
 </script>
</head>

<body>
 <div class="demo">
  <div id="container" class="ui-widget-content">
   <div id="inside"></div>
  </div>
 </div>
</body>

FYI - I just tested this in Firefox and Safari on a Mac.

Ken Earley
ok so how does that solve my problem at all. that is exactly what I have and when you move the cursor it is not staying on the side of the container.
ngreenwood6
Sorry. I cannot see what's happening on your computer. I tested this code in Firefox and Safari on a Mac and it works correctly. If you are really interested in getting a solution to your problem, maybe you can provide more information. (ie: which browsers does this happen in? provide a screen shot)
Ken Earley