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
Post a Comment