I am using jQuery UI to create a draggable <div>
. The <div>
is absolutely positioned to the bottom-right or top-left using CSS:
.dragbox {
position: absolute;
width: 140px;
min-height: 140px; /* I need to use min-height */
border: 3px solid black;
padding: 10px;
}
.bottom {
bottom: 5px; /* causes box to resize when dragged */
right: 5px;
}
.top {
top: 5px; /* does not cause box to resize */
left: 5px;
}
The HTML looks like this:
<div class="dragbox bottom">
Bottom Box :(
</div>
<div class="dragbox top">
Top Box :)
</div>
The JavaScript is $('.dragbox').draggable();
to make the <div>
elements draggable. The top-left <div>
works as expected, but the bottom-right <div>
resizes when dragged. If I change the min-height
poperty of .dragbox
to height
I see the expected behavior for both boxes, but I need to use min-height
for this because I don't know the length of the inner content.
How do I position the <div>
in the bottom-right and enable dragging without having the <div>
resize when dragged? The top-left and bottom-right <div>
elements should behave the same way.
DEMO (I use Chrome 27 and Safari 6)