XHanch Studio Log in | Register | Cart

Forum

Notifications
Clear all

[How to] Stretch background image for div, body, or other HTML element

XHanch
(@xhanch-alt)
Member Admin

With CSS 3, now you can stretch background image for a body, div element or other HTML element.

Here are the CSS codes:

html,
body,
div{
    width:100%;
    height:100%;
    position:relative;
    background: url(img/bg.jpg) no-repeat center center;
    -webkit-background-size:cover; /*for webKit*/
    -moz-background-size:cover; /*Mozilla*/
    -o-background-size:cover; /*opera*/
    background-size:cover; /*generic*/
}
Quote
Topic starter Posted : 04/10/2012 6:37 pm
Share:

× Close Menu