Created
October 21, 2013 16:43
-
-
Save arvindang/7086930 to your computer and use it in GitHub Desktop.
Find window height, and append section background-image height in CSS to match.
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
section { | |
margin-bottom: 40px; | |
} | |
.main { | |
background: url(http://img.timeinc.net/time/photoessays/2008/trees/franklin_trees_01.jpg) no-repeat center center; | |
-webkit-background-size: cover; | |
-moz-background-size: cover; | |
-o-background-size: cover; | |
background-size: cover; | |
} |
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> | |
<head> | |
<script src="http://code.jquery.com/jquery.min.js"></script> | |
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" /> | |
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script> | |
<script src="http://code.jquery.com/jquery-git2.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<section class="main"></section> | |
<section>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cumque iste modi sint libero excepturi voluptate recusandae ipsam reprehenderit. Illo quis harum eius sint earum rerum magnam cumque maiores nesciunt repellendus.</section> | |
<section>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nemo eos laborum quam quidem unde iusto hic consequuntur magni vero natus doloremque iure assumenda quis dignissimos accusantium voluptatibus cumque in aperiam.</section> | |
</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
mainHeight = $(window).height(); | |
console.log(mainHeight); | |
$('.main').css({"height": mainHeight}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment