Skip to content

Instantly share code, notes, and snippets.

@pcalves
Last active August 29, 2015 13:56
Show Gist options
  • Save pcalves/9229293 to your computer and use it in GitHub Desktop.
Save pcalves/9229293 to your computer and use it in GitHub Desktop.
Full page background
/**
* Full page background
* http://css-tricks.com/perfect-full-page-background-image/
*/
.bg {
position: fixed;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
}
.bg img {
position: absolute;
top: 0
left: 0;
right: 0;
bottom: 0;
margin: auto;
min-width: 50%;
min-height: 50%;
}
<!-- content to be placed inside <body>…</body> -->
<div class="bg">
<img src="http://placehold.it/1024x768" alt="" />
</div>
// alert('Hello world!');
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment