Created
January 13, 2012 05:20
-
-
Save froop/1604802 to your computer and use it in GitHub Desktop.
[JavaScript] ウィンドウのリサイズに合わせてコンテンツの高さを調整
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function resizeContents() { | |
var contentsElem = document.getElementById("contents"), | |
headerElem = document.getElementById("header"), | |
parentH = contentsElem.offsetParent.clientHeight, | |
headerH = headerElem.offsetHeight, | |
paddingH = 10 * 2; | |
try { | |
contentsElem.style.height = (parentH - headerH - paddingH) + "px"; | |
} catch (e) { | |
// ignore error | |
} | |
} | |
window.onload = function () { | |
resizeContents(); | |
}; | |
window.onresize = function () { | |
resizeContents(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment