Search code examples
cssbackgroundcover

CSS background 100% height


html,body{
    background: linear-gradient(to right top, #336e7b 0%, #8e44ad 50%, #e74c3c 100%) repeat scroll 0 0 #abb7b7;
    margin:0;
    padding:0;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

JSFiddle: http://jsfiddle.net/losiuhoi/1ujk40wh/1/

How can I set the background of body to 100% height?


Solution

  • Set height of the body to 100%, otherwise it takes only as much as it's necessary for content (.msg div).

    html, body {
        height: 100%;
    }
    

    Demo: http://jsfiddle.net/dfsq/1ujk40wh/2/