Make body have 100% of the browser height

后端 未结 21 1348
离开以前
离开以前 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:52

    If you want to keep the margins on the body and don't want scroll bars, use the following css:

    html { height:100%; }
    body { position:absolute; top:0; bottom:0; right:0; left:0; }
    

    Setting body {min-height:100%} will give you scroll bars.

    See demo at http://jsbin.com/aCaDahEK/2/edit?html,output .

提交回复
热议问题