Make body have 100% of the browser height

后端 未结 21 1361
离开以前
离开以前 2020-11-22 00:26

I want to make body have 100% of the browser height. Can I do that using CSS?

I tried setting height: 100%, but it doesn\'t work.

I want to set

21条回答
  •  囚心锁ツ
    2020-11-22 00:40

    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;
        min-height: 100%;
    }
    html body {
        min-height: 100%
    }
    

    Works for all major browsers: FF, Chrome, Opera, IE9+. Works with Background images and gradients. Scrollbars are available as content needs.

提交回复
热议问题