“Height=100%” is not working in html when using <!DOCTYPE>?

前端 未结 3 1032
慢半拍i
慢半拍i 2020-11-30 08:58

When I use HTML without DOCTYPE, my HTML page Height=100% is working.

But when I use DOCTYPE, height is not working correctly.

3条回答
  •  爱一瞬间的悲伤
    2020-11-30 09:12

    Like everyone said the main part of the solution is to put

    html, body{'height=100%'}

    But its also really important to set every single ancestor's height to be 100%. for example if your code is as follows

    
        
    lets say this is the div you want to make 100%

    if #scnddiv is the div you want to make 100%, not only you have to make html and body 100% but also #firstdiv. So it will look something like this

    html, body, #firstdiv {height:100%}
    

    then you can make anything in that div to be 100%.

    I hope this helps.

提交回复
热议问题