jquery - More efficient way of using javascript to stick columns to bottom of page? -


i've been designing web site while, 2 column layout, , want each column go bottom of page regardless of resolution. accomplish this, have 2 javascript files - 1 adjusts column length fit browser window, , other javascript file match resized one. 1 major problem have, if change browser window size, columns no auto adjust, may not go bottom of page. wondering if there way in 1 file, , importantly make columns stick bottom of page no matter window size is. here code each javascript file:

adjust column height browser window:

$(function(){     var grid = $(window).height();     var gridfinal = grid - 140;     $('.grid').css({'min-height': ((gridfinal))+'px'}); }); 

adjust other column match resized one:

window.onload =  getidheight;  function getidheight() {     var myhomeheight = document.getelementbyid("home").offsetheight;     document.getelementbyid("home-services").style.height = myhomeheight - 15 +"px"; }   window.addeventlistener('load', function (){  var mynewsheight = document.getelementbyid("blog").offsetheight; document.getelementbyid("social-media").style.height = mynewsheight - 15 +"px"; });  window.addeventlistener('load', function (){  var myaboutheight = document.getelementbyid("references").offsetheight;     document.getelementbyid("about").style.height = myaboutheight - 25 +"px"; });  window.addeventlistener('load', function (){  var myservicesheight = document.getelementbyid("services").offsetheight; document.getelementbyid("guidelines").style.height = myservicesheight - 15 +"px"; });  window.addeventlistener('load', function (){  var mytipsheight = document.getelementbyid("tips").offsetheight;     document.getelementbyid("recommendations").style.height = mytipsheight - 20 +"px"; });  window.addeventlistener('load', function (){  var mycontactheight = document.getelementbyid("contact-info").offsetheight;     document.getelementbyid("email").style.height = mycontactheight - 15 +"px"; }); 

any here appreciated. if there simpler way of doing increases functionality, please let me know.

you css. set height of html & body 100%, set columns height 100%

fiddle here : demo

html,body{     height:100%; } #column1{     height:100%; } #column2{     height:100%; } 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -