javascript - Take height of parent and assign to child with jQuery -


i have css , html structure:

.body_wrapper {    height: 100%;    }    .forumcontents {    width: calc(100% - 290px) !important;    float: left;    }    .sidebar_container {    width: 270px;    float: right;    height: 100%;    }    .clearfix {     zoom: 1;     clear: both;    }
<div class="body_wrapper clearfix">      <div class="forumcontents"></div>      <div class="sidebar_container"></div>  </div>

unfortunately, need float .sidebar_container, float, div doesn't take 100% of height of .body_wrapper , reasons can't use absolute positioning.

i tried display: table-cell .sidebar_container doesn't work, thought solution take .body_wrapper height after page loading ad assign .sidebar_container.

how can jquery?

here jquery

$(function () {     $(".sidebar_container").height($(".body_wrapper").height()); }); 

here fiddle showing in action (i added borders show boundaries): http://jsfiddle.net/48uxr49p/

however, in jsfiddle, using height:100% on sidebar works fine (i commented out show jquery works). may want dig around see if there element/css preventing height:100% working.

here jsfiddle demonstrating height:100% works: http://jsfiddle.net/w3dmx7qm/


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

mysql - FireDac error 314 - but DLLs are in program directory -

python - build a suggestions list using fuzzywuzzy -