Make body have 100% of the browser height

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

    Only with 1 line of CSS… You can get this done.

    body{ height: 100vh; }
    
    0 讨论(0)
  • 2020-11-22 00:57

    A quick update

    html, body{
        min-height:100%;
        overflow:auto;
    }
    

    A better solution with today's CSS

    html, body{ 
      min-height: 100vh;
      overflow: auto;
    }
    
    0 讨论(0)
  • 2020-11-22 00:57
    @media all {
    * {
        margin: 0;
        padding: 0;
    }
    
    html, body {
        width: 100%;
        height: 100%;
    } }
    
    0 讨论(0)
提交回复
热议问题