Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery Change Child Deminsions to match Parents after resize

I have a parent div with a child div inside. The parent div is using jquery Ui resizable. How can i make the child div inherent the parent div dimensions in real time when parent div is resized.

Here's what i have http://jsfiddle.net/dtxhe/7/

After resize, the child div is not resizing according to it's parent.

like image 902
Hussein Avatar asked Dec 28 '22 02:12

Hussein


2 Answers

You can also use this :

http://jsfiddle.net/dtxhe/11/

Code :

$("#container").resizable({ alsoResize: '#child' });
like image 134
CronosS Avatar answered Feb 23 '23 16:02

CronosS


You need to utilize the resize event of the resizable object.

http://jsfiddle.net/dtxhe/10/

$("#container").resizable({
   resize: function(event, ui) {
       var parentwidth = $("#container").innerWidth();
       var parentheight = $("#container").innerHeight();
       $("#child").css({'width':parentwidth, 'height':parentheight});
   }
});
like image 29
Dutchie432 Avatar answered Feb 23 '23 16:02

Dutchie432