Keep a draggable div inside its parent

Viewed 13796

I have got a draggable div tag and I'd like it not to overflow from its parent while being dragged.

<script>
    $('.children').resizeable().draggable();//from jquerUI
</script>

<style>
    .parent{
        overflow: hidden;
        position: relative;
        width: 1000px;
        height: 1000px;
    }
    .children{
        width: 100px;
        height: 100px;
        position: absolute;
    }
</style>

<div class="parent">
   <div class="children"><div>
</div>

How can I limit the children's position and size inside the parent.

2 Answers
Related