[英]100% height issue with IE8 doctype declaration
好的,我有一個簡單的HTML網頁。 問題是,當我在頁面開頭指定Doctype時,我的樣式表高度:100%不起作用。
如果我刪除doctype聲明,那么一切都會按預期進行。 所以有人知道為什么會這樣嗎? 我應該使用什么文檔類型?
我也嘗試使用“嚴格”的DOCTYPE聲明,但是仍然存在相同的問題。 提前致謝。
以下是完整的HTML,其中height:100%不起作用:
<!DOCTYPE html PUBLIC "-//VYOM//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/transitional.dtd">
<html>
<body>
<div style="background-color:red; height:100%;">
testing 123...
</div>
</body>
如果刪除文檔類型,DIV將按預期占用可用高度的100%:
<html>
<body>
<div style="background-color:red; height:100%;">
testing 123...
</div>
</body>
</html>
加:
body, html {
height:100%
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.