我很害怕。在Internet Explorer和Mozilla Firefox中,此頁面非常高!我一直在使用jQuery來設置元素的高度幾乎與元素一樣高。它在Chrome中看起來很完美,但IE和FF渲染的頁面非常高。更值得一提的是,使用Firefox的檢查器時,我可以看到該頁面遠遠超出了元素的高度!爲什麼我的頁面比<html>元素高?
jQuery的:
(function($){
var resize = function(){
var height = $('html').height();
$('#wrap > div').height(height-38);
$('html').height(height); // Added this to try and fix the height
};
$(window).resize(resize).load(resize);
})(jQuery);
的HTML佈局:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<!-- ... --->
</head>
<body>
<div id="wrap"><div> <!-- I want the child of #wrap to be the height of the entire page. -->
<div id="left"><div>
<!-- ... -->
</div></div>
<div id="main">
<!-- ... -->
<div class="clear"></div>
<div id="body">
<!-- ... -->
</div>
</div>
</div></div>
</body>
</html>
的CSS:
html{height: 100%;}
body{background: url('images/body.jpg') no-repeat fixed left top; border: 8px solid #BBB0A2; border-width: 8px 0 0 6px; min-width: 902px;}
#wrap{max-width: 1130px;}
#wrap > div{float: right;}
#main{float: left; width: 630px; height: 100%; padding: 10px 20px 20px 20px; background: #FFFFFF;}
#body{margin-top: 20px; font: 13px/18px Georgia, serif; color: #AE9073; position: relative;}
這裏的網站我想一起工作:http://www.phoenixarizonashutters.com/
T爲你提供幫助。
是因爲你有填充嗎?我不是一個Web開發人員,但是主要佔用容器+填充100%的事實使它比容器更大? – Colton
你有20px左右和10px頂部和20px底部填充... –
不知道這是什麼意思 - > _「設置元素的高度幾乎與元素一樣高。」_ – Sparky