If you go to www.joinbunch.com and resize the browser, you can see that the background image scales very nicely when resized.
What would be the best way to accomplish this?
If you go to www.joinbunch.com and resize the browser, you can see that the background image scales very nicely when resized.
What would be the best way to accomplish this?
The easiest way is with css background-size cover
. This will scale an image so it will cover the entire area.
#myelement {
background: url(myback.png) cover;
}
full syntax:
#myelement {
background-image:url(myback.png);
background-size:cover;
}
The background image of the <div>
containing the image must have the attribute width
to a 100%
... or some other percentage.
To explain it a little bit more:
Check this Link http://css-tricks.com/perfect-full-page-background-image/
Via CSS3
html {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
"USUAL" way
HTML markup
<div id="bg">
<img src="images/bg.jpg" alt="">
</div>
CSS markup
#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%;
}
They also provide a demo:
http://css-tricks.com/examples/FullPageBackgroundImage/css-2.php
I recommend that page, it has a lot of tricks for css.
Hope it helps!