The simplest solution is as follows (note the changes to #left and #right in SCSS):
SCSS:
#container { width: 500px; height: 100px; background: #f9f9f9; } #nav { width: 100px; height: 100px; background: #e9e9e9; cursor: move; } #left { width: 10px; height: 100px; position: absolute; top:0; left:0px; background: #a9a9a9; cursor: w-resize; &:hover { background: #999; } } #right { width: 10px; height: 100px; position:absolute; top:0; right:0px; background: #a9a9a9; cursor: e-resize; &:hover { background: #999; } }
JavaScript:
var cont = $("#container") var nav = $("#nav") var left = $("#left") var right = $("#right") nav.draggable({ containment: cont }); right.draggable({ containment: cont, drag: function(e, ui) { nav.width(ui.position.left); } });
The only problem was that you were thinking too much about your JavaScript. Ui.position.left had all the necessary information. All I did was change the contents from floating position to position: absolute;
source share