XHanch Studio Log in | Register | Cart

Forum

[How to] Stretch ba...
 
Notifications
Clear all

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

1 Posts
1 Users
0 Reactions
1,170 Views
XHanch
(@xhanch-alt)
Posts: 2105
Member Admin
Topic starter
 

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*/
}
 
Posted : 04/10/2012 6:37 pm
Share:

× Close Menu