I have a draggable div to which I want to set containment 80% of parent. How can I achieve this ?
$( ".content-columns-sep" ).draggable({
axis: "x",
containment: "parent",
cursor: "crosshair",
grid: [10, 0],
drag: function(event, ui) {
..
}
});
As Neil suggested, you can use an internal div that is 80% of its parents size, and then constraint dragging to within that div. Here is a quick-and-dirty example on jsfiddle.
For reference, the markup is:
The styles are:
And the code is: