javascript - Can't get height of div to adjust -
i'm in pickle.
i'm working on layout, , need main div adjust window size, mainly middle div make scrollbar upon resizing. it's acting table cell currently, why it's forcing become taller instead of using scrollbar. it's in containing div in efforts keep doing though.
<div id="all"> <div id="voltron"> <div id="mainsidebar">ok</div> <div id="content"> <div id="ticker">please</div> <div class="wrap"> <div id="postsgohere"> <p>lorem ipsum dolor sit amet, ...</p> </div> <div id="rightsidebar">well then.</div> </div> </div> </div> </div>
i resorted jquery, , though found code thing, it's not working.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type='text/javascript'> $(function(){ $('#all') .css({'height': (($(window).height()))+'px'}); $(window).resize(function(){ $('#all') .css({'height': (($(window).height()))+'px'}); }); }); </script>
i've tried setting max height, i've tried setting vh instead of percent, i've tried containing it, , feel i've exhausted pretty decent amount of time on conundrum myself help.
here entire code, in case helps. i'm way i'm doing reason it's not working.
so, idea fix this? , why i'm trying isn't working?
edit: need specify again: want entire "table" fit window, purple div 1 should scroll. problem is, though i've set overflow-y: scroll;
changes size of entire container. entire table grows past window compensate overflow.
your code looks good, don't see takes exact size of window. see better if subtracted little off of , added overflow-y:scroll
#all
instead of container:
#all { background-color: red; max-width: 100%; max-height: 100%; overflow-y: scroll; }
$(function () { $('#all').css('height', $(window).height()-50 + 'px'); $(window).resize(function () { $('#all').css('height', $(window).height()-50 + 'px'); }); });
edited: following edit, , know threw off layout completely, thing worked me, if wanted purple 1 move only, remove table-cell display , set height container instead of all, , adding scroll that:
#all { background-color: red; max-width: 100%; max-height: 100%; } #postsgohere { background-color: purple; max-height: inherit; overflow-y: scroll; }
$(function () { $('#postsgohere').css('height', $(window).height()-50 + 'px'); $(window).resize(function () { $('#postsgohere').css('height', $(window).height()-50 + 'px'); }); });
Comments
Post a Comment