Last active
August 29, 2015 14:17
-
-
Save ezakto/36691d17dd861f911e92 to your computer and use it in GitHub Desktop.
Full-height elements with css/js
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Demo</title> | |
<link rel="stylesheet" href="style.css"> | |
<script> | |
(function(){ | |
var s = document.createElement('style'); | |
var f = function () { s.innerHTML = '.full-height{height:'+window.innerHeight+'px}'; }; | |
f(); window.addEventListener('resize', f); | |
document.getElementsByTagName('head')[0].appendChild(s); | |
}()); | |
</script> | |
</head> | |
<body> | |
<header class="full-height"> | |
<h1>There.</h1> | |
</header> | |
<div id="main"> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque eveniet incidunt, assumenda alias quod. Quia omnis, odit suscipit inventore ut, expedita modi culpa at excepturi dicta reprehenderit alias sit nisi!</p> | |
</div> | |
</body> | |
</html> |
This file contains 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(){ | |
var s = document.createElement('style'); | |
var f = function () { s.innerHTML = '.full-height{height:'+window.innerHeight+'px}'; }; | |
f(); window.addEventListener('resize', f); | |
document.getElementsByTagName('head')[0].appendChild(s); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment