how to make a full screen div, and prevent size to be changed by content?

前端 未结 8 2103
予麋鹿
予麋鹿 2020-12-13 13:05

for my web application, i would like the main div to be full screen (both width and height = 100%), and regardless of content, i want it to stay at that size. that means, if

相关标签:
8条回答
  • 2020-12-13 13:35

    Or even just:

    <div id="full-size">
      Your contents go here
    </div>
    
    html,body{ margin:0; padding:0; height:100%; width:100%; }
    #full-size{
      height:100%;
      width:100%;
      overflow:hidden; /* or overflow:auto; if you want scrollbars */
    }
    

    (html, body can be set to like.. 95%-99% or some such to account for slight inconsistencies in margins, etc.)

    0 讨论(0)
  • 2020-12-13 13:36
    #fullDiv {
        height: 100%;
        width: 100%;
        left: 0;
        top: 0;
        overflow: hidden;
        position: fixed;
    }
    
    0 讨论(0)
提交回复
热议问题