JQuery Resizable: Unable to size child element to full height of parent

564 views Asked by At

I'm using JQuery resizable and am unable to resize the child element contained in a parent div to the full height of the parent.

Here an example in jsfiddle: Try to drag the red box resizable handle down to make the red box fit the parent. http://jsfiddle.net/ozsLegy4/3/

<div id="container1" class="container box">
    <div id="box1" class="widget-container box">
        <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit,
        </p>
    </div>
</div>

    $(document).ready(function(){
        $('#box1').css('top', '0px');
        $('#box1').css('left', '0px');
        $('#box1').css('z-index', 10);

        $('.box').each(function(index){
            $(this).draggable({
                containment: "parent"
            });

            $(this).resizable({
                containment: "parent"
            });    
        });
    });

.container{
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    border: 3px solid green;
    width: 100%;
    height: 100px;
    margin: 0px;
    position: relative;
    z-index: 400;
}

.widget-container{
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    border: 3px solid red;
    padding: 10px;
    overflow: hidden;
    width: 40px;
    height: 50px;
    position:absolute;
    margin: 0px;
}

I assume the parent is not height enough to allow the drag handle to move further down.

Any ideas how to work around this?

Thanks!

1

There are 1 answers

0
checkmate711 On

I took out the box-sizing css statements for container and widget-container and it works as expected.

box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;