I have got a vertical menu on the left side of the screen, and i want to take 100% height of the resolution, but if the div(of the menu) needs more, i want to appear scroll. My
Works everywhere
JS
function overflowFillHeight(el,listener){
var sumH = 0;
if(el){
var parEls = el.parentNode.childNodes;
var style = null;
if(parEls.length > 1){
for(var j = 0; j < parEls.length; j++){
if(parEls[j].nodeType != 3){
if(parEls[j] != el ){
sumH += parEls[j].clientHeight;
if(typeof window.getComputedStyle(parEls[j]) != 'undefined'){
style = window.getComputedStyle(parEls[j]);
}else if(typeof parEls[j].currentStyle != 'undefined'){
style = parEls[j].currentStyle;
};
if(style){
sumH += parseInt(style.marginTop);
sumH += parseInt(style.marginBottom);
sumH += parseInt(style.borderTopWidth);
sumH += parseInt(style.borderBottomWidth);
};
};
};
};
};
style = null;
if(typeof window.getComputedStyle(el) != 'undefined'){
style = window.getComputedStyle(el);
}else if(typeof el.currentStyle != 'undefined'){
style = el.currentStyle;
};
if(style){
sumH += parseInt(style.marginTop);
sumH += parseInt(style.marginBottom);
sumH += parseInt(style.borderTopWidth);
sumH += parseInt(style.borderBottomWidth);
};
el.style.height = (el.parentNode.clientHeight - sumH)+'px';
if(!listener){
window.addEventListener('resize',function(){
overflowFillHeight(el,true);
},false);
};
};
};
example
Untitled Document
1
2
3