jQuery UI #8044

http://bugs.jqueryui.com/ticket/8044

by TJ VanToll

HTML

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>

<p><a href="http://bugs.jqueryui.com/ticket/8044">jQuery UI #8044</a> - <code>resizable</code> with <code>helper</code> and <code>containment</code> options set incorrectly changes positions when resized.  Interestingly this is fixed by adding normalize.css.</p>

<div id="resizableContainer">
    <div class="resizable"></div>
</div>

CSS

body { padding: 20px; }
p { line-height: 1.5; margin-bottom: 20px; }

#resizableContainer {
    width: 400px;
    height: 300px;
    border: 1px solid red;
    position: relative;
}
.resizable {
    position: absolute;
    border: 1px solid blue;
    top: 50px;
    left: 50px;
    height: 100px;
    width: 100px;
}

JavaScript

$('.resizable').resizable({
   helper: 'whatever',
   handles: 'all',
   containment: '#resizableContainer'
});