【问题标题】:Jquery ui resizing from top bugsJquery ui 从顶级错误调整大小
【发布时间】:2015-05-23 13:00:51
【问题描述】:

当我尝试从顶部调整元素的大小时(即使它看起来正在调整大小),我注意到底部被调整了大小。

HTML:

<div class="resizeme" style="background:yellow;">Resize me from the top</div>

JS

$(".resizeme").resizable({
    handles: "n,s,e,w"
});

jsfiddle:

http://jsfiddle.net/mody5/4x3r8vsq/

我该如何纠正?

【问题讨论】:

    标签: jquery jquery-ui jquery-ui-resizable


    【解决方案1】:

    通过调整大小,您改变了高度和宽度,您并没有改变可调整大小元素中内容的定位或对齐方式。

    所以,实际上,可调整大小的元素的行为符合预期,只是在没有参考点的情况下看起来很奇怪。可以把它想象成从你抓住的把手上拉伸它,当你抓住的边缘移动时,其他边保持不动。

    试试这个:

    jsFiddle

    $(document).ready(function() {
      $(".resizeme").resizable({
        handles: "n,s,e,w"
      });
    });
    .resizeme {
      position: relative;
      top:20px;
      background: yellow;
      padding: 6px;
      height: 100px;
      width: 200px;
    }
    #top {
      position: fixed;
      top: 28px;
      background: red;
    }
    #bottom {
      position: fixed;
      bottom: 60px;
      background: blue;
    }
    <link href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
    
    <div class="resizeme">
    </div>
    <span id="top">Resize me from the top</span><span id="bottom">Resize me from the bottom</span>

    【讨论】:

      猜你喜欢
      • 2012-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-17
      • 1970-01-01
      • 1970-01-01
      • 2015-10-04
      • 1970-01-01
      相关资源
      最近更新 更多