How do you make one child div determine the parents height and force a second child div to fit inside the...





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















So I have 2 children div inside a parent div.
What I want to do is have the left hand child div determine the height of the parent. And then have the second right hand side child div always be the same height as the parent regardless of how much content is inside this.
This would be super easy if I could hard code the size of the left hand child div but that left hand child can have a varying height due to the text are inside it



see attached code.



At the moment the right hand side is making the parent bigger then the left.
And the final outcome I want is for it to always be the height of the parent no matter how big you make the left text area.



https://jsfiddle.net/e29o6jnz/



<script>
#topDiv {
background-color: lightblue;
max-height: 17rem;
padding: 10px;
box-sizing: border-box;
display: flex;
flex-direction: row;
}

#insideDiv1 {

}

#insideDiv2 {
background-color: pink;
overflow-y: auto;
height: auto;
}
</script>

<div id="topDiv">
<div>
No scroll content
</div>
<div id="insideDiv1">
<textarea style="margin: 0px; width: 171px; height: 131px;">hello</textarea>
</div>
<div id="insideDiv2" style="">
Some inside content
More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br><br>
</div>
</div>









share|improve this question


















  • 1





    Did you try to use jQuery?

    – Jared Chu
    Nov 23 '18 at 6:49


















0















So I have 2 children div inside a parent div.
What I want to do is have the left hand child div determine the height of the parent. And then have the second right hand side child div always be the same height as the parent regardless of how much content is inside this.
This would be super easy if I could hard code the size of the left hand child div but that left hand child can have a varying height due to the text are inside it



see attached code.



At the moment the right hand side is making the parent bigger then the left.
And the final outcome I want is for it to always be the height of the parent no matter how big you make the left text area.



https://jsfiddle.net/e29o6jnz/



<script>
#topDiv {
background-color: lightblue;
max-height: 17rem;
padding: 10px;
box-sizing: border-box;
display: flex;
flex-direction: row;
}

#insideDiv1 {

}

#insideDiv2 {
background-color: pink;
overflow-y: auto;
height: auto;
}
</script>

<div id="topDiv">
<div>
No scroll content
</div>
<div id="insideDiv1">
<textarea style="margin: 0px; width: 171px; height: 131px;">hello</textarea>
</div>
<div id="insideDiv2" style="">
Some inside content
More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br><br>
</div>
</div>









share|improve this question


















  • 1





    Did you try to use jQuery?

    – Jared Chu
    Nov 23 '18 at 6:49














0












0








0








So I have 2 children div inside a parent div.
What I want to do is have the left hand child div determine the height of the parent. And then have the second right hand side child div always be the same height as the parent regardless of how much content is inside this.
This would be super easy if I could hard code the size of the left hand child div but that left hand child can have a varying height due to the text are inside it



see attached code.



At the moment the right hand side is making the parent bigger then the left.
And the final outcome I want is for it to always be the height of the parent no matter how big you make the left text area.



https://jsfiddle.net/e29o6jnz/



<script>
#topDiv {
background-color: lightblue;
max-height: 17rem;
padding: 10px;
box-sizing: border-box;
display: flex;
flex-direction: row;
}

#insideDiv1 {

}

#insideDiv2 {
background-color: pink;
overflow-y: auto;
height: auto;
}
</script>

<div id="topDiv">
<div>
No scroll content
</div>
<div id="insideDiv1">
<textarea style="margin: 0px; width: 171px; height: 131px;">hello</textarea>
</div>
<div id="insideDiv2" style="">
Some inside content
More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br><br>
</div>
</div>









share|improve this question














So I have 2 children div inside a parent div.
What I want to do is have the left hand child div determine the height of the parent. And then have the second right hand side child div always be the same height as the parent regardless of how much content is inside this.
This would be super easy if I could hard code the size of the left hand child div but that left hand child can have a varying height due to the text are inside it



see attached code.



At the moment the right hand side is making the parent bigger then the left.
And the final outcome I want is for it to always be the height of the parent no matter how big you make the left text area.



https://jsfiddle.net/e29o6jnz/



<script>
#topDiv {
background-color: lightblue;
max-height: 17rem;
padding: 10px;
box-sizing: border-box;
display: flex;
flex-direction: row;
}

#insideDiv1 {

}

#insideDiv2 {
background-color: pink;
overflow-y: auto;
height: auto;
}
</script>

<div id="topDiv">
<div>
No scroll content
</div>
<div id="insideDiv1">
<textarea style="margin: 0px; width: 171px; height: 131px;">hello</textarea>
</div>
<div id="insideDiv2" style="">
Some inside content
More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br> More inside content
<br><br>
</div>
</div>






html css






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 4:11









1seanr1seanr

87111




87111








  • 1





    Did you try to use jQuery?

    – Jared Chu
    Nov 23 '18 at 6:49














  • 1





    Did you try to use jQuery?

    – Jared Chu
    Nov 23 '18 at 6:49








1




1





Did you try to use jQuery?

– Jared Chu
Nov 23 '18 at 6:49





Did you try to use jQuery?

– Jared Chu
Nov 23 '18 at 6:49












1 Answer
1






active

oldest

votes


















1














We can not this task with only css. For this We need to get left child div height with js and assign it to right child max-height and assign to parent div height.





jQuery(document).ready(function(){
$('textarea').mouseup(function(){
var height = $(this).parent().height();

$(this).parents().find('.parent').height(height);
$(this).parent().next().css({'max-height' : height});
});
});




 .parent{ max-width:700px; border:solid 3px #ff0000; float:left; width:100%; position:relative;   }
.right-child , .child-left{ width:40%; float:left;}
.right-child{ overflow:auto; }




<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<div class="parent">
<div class="child-left">Lorem Ipsum is simply dummy text of the printing and <textarea style="margin: 0px; height: 144px; width: 100%;"></textarea></div>
<div class="right-child">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</div>

</div>







share|improve this answer
























  • I adapted this a little and managed to get this which worked out well enough in the end. jsfiddle.net/w045mu1b

    – 1seanr
    Nov 26 '18 at 3:50












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440560%2fhow-do-you-make-one-child-div-determine-the-parents-height-and-force-a-second-ch%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














We can not this task with only css. For this We need to get left child div height with js and assign it to right child max-height and assign to parent div height.





jQuery(document).ready(function(){
$('textarea').mouseup(function(){
var height = $(this).parent().height();

$(this).parents().find('.parent').height(height);
$(this).parent().next().css({'max-height' : height});
});
});




 .parent{ max-width:700px; border:solid 3px #ff0000; float:left; width:100%; position:relative;   }
.right-child , .child-left{ width:40%; float:left;}
.right-child{ overflow:auto; }




<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<div class="parent">
<div class="child-left">Lorem Ipsum is simply dummy text of the printing and <textarea style="margin: 0px; height: 144px; width: 100%;"></textarea></div>
<div class="right-child">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</div>

</div>







share|improve this answer
























  • I adapted this a little and managed to get this which worked out well enough in the end. jsfiddle.net/w045mu1b

    – 1seanr
    Nov 26 '18 at 3:50
















1














We can not this task with only css. For this We need to get left child div height with js and assign it to right child max-height and assign to parent div height.





jQuery(document).ready(function(){
$('textarea').mouseup(function(){
var height = $(this).parent().height();

$(this).parents().find('.parent').height(height);
$(this).parent().next().css({'max-height' : height});
});
});




 .parent{ max-width:700px; border:solid 3px #ff0000; float:left; width:100%; position:relative;   }
.right-child , .child-left{ width:40%; float:left;}
.right-child{ overflow:auto; }




<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<div class="parent">
<div class="child-left">Lorem Ipsum is simply dummy text of the printing and <textarea style="margin: 0px; height: 144px; width: 100%;"></textarea></div>
<div class="right-child">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</div>

</div>







share|improve this answer
























  • I adapted this a little and managed to get this which worked out well enough in the end. jsfiddle.net/w045mu1b

    – 1seanr
    Nov 26 '18 at 3:50














1












1








1







We can not this task with only css. For this We need to get left child div height with js and assign it to right child max-height and assign to parent div height.





jQuery(document).ready(function(){
$('textarea').mouseup(function(){
var height = $(this).parent().height();

$(this).parents().find('.parent').height(height);
$(this).parent().next().css({'max-height' : height});
});
});




 .parent{ max-width:700px; border:solid 3px #ff0000; float:left; width:100%; position:relative;   }
.right-child , .child-left{ width:40%; float:left;}
.right-child{ overflow:auto; }




<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<div class="parent">
<div class="child-left">Lorem Ipsum is simply dummy text of the printing and <textarea style="margin: 0px; height: 144px; width: 100%;"></textarea></div>
<div class="right-child">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</div>

</div>







share|improve this answer













We can not this task with only css. For this We need to get left child div height with js and assign it to right child max-height and assign to parent div height.





jQuery(document).ready(function(){
$('textarea').mouseup(function(){
var height = $(this).parent().height();

$(this).parents().find('.parent').height(height);
$(this).parent().next().css({'max-height' : height});
});
});




 .parent{ max-width:700px; border:solid 3px #ff0000; float:left; width:100%; position:relative;   }
.right-child , .child-left{ width:40%; float:left;}
.right-child{ overflow:auto; }




<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<div class="parent">
<div class="child-left">Lorem Ipsum is simply dummy text of the printing and <textarea style="margin: 0px; height: 144px; width: 100%;"></textarea></div>
<div class="right-child">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</div>

</div>








share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 10:07









Falguni PrajapatiFalguni Prajapati

1317




1317













  • I adapted this a little and managed to get this which worked out well enough in the end. jsfiddle.net/w045mu1b

    – 1seanr
    Nov 26 '18 at 3:50



















  • I adapted this a little and managed to get this which worked out well enough in the end. jsfiddle.net/w045mu1b

    – 1seanr
    Nov 26 '18 at 3:50

















I adapted this a little and managed to get this which worked out well enough in the end. jsfiddle.net/w045mu1b

– 1seanr
Nov 26 '18 at 3:50





I adapted this a little and managed to get this which worked out well enough in the end. jsfiddle.net/w045mu1b

– 1seanr
Nov 26 '18 at 3:50




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440560%2fhow-do-you-make-one-child-div-determine-the-parents-height-and-force-a-second-ch%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to send String Array data to Server using php in android

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Is anime1.com a legal site for watching anime?