开发者

jquery resizable cursor is not stying with margin auto

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开发者_StackOverflow. Is there a way to make this work or just another way to center the page without using auto?


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"></script>
    <script type="text/javascript" src="http://jqueryui.com/ui/ui.core.js"></script>
    <script type="text/javascript" src="http://jqueryui.com/ui/ui.resizable.js"></script>

    <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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜