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

前端 未结 3 1030
慢半拍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:14

    Adding a DOCTYPE switches you from quirks mode to standards mode. In standards mode, the html and body elements do not default to 100% of the size of the viewport (browser window); instead, they are only as large as they need to be to contain their children. The table height of 100% means 100% of the containing element, but that's only as large as it needs to be to contain the contents of the table. Quirks mode is an emulation of the behavior of older browsers, in which the html and body elements filled the viewport.

    To fix the problem, you just need to add this to your document:

    
    

提交回复
热议问题