我有一個簡單的HTML頁面,側邊欄浮動到左側,所有內容在右側。在主要內容區域,我有一個。但是,當我使用CSS將幀的高度設置爲100%時,由於某種原因,它似乎溢出了包含div
,導致我的內容之後出現少量空白。設置iframe高度爲100%似乎溢出包含div
這裏是我的HTML內容:
<div id="container">
<div id="sidebar">
<p>Sidebar content</p>
</div>
<div id="content">
<iframe id="contentFrame"></iframe>
</div>
</div>
這裏是我的CSS:
html, body {
height: 100%;
}
#container {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
background-color: grey;
}
#sidebar {
width: 100px;
float: left;
background-color: blue;
height: 100%;
}
#content {
margin-left: 100px;
height: 100%;
background-color: yellow;
}
#contentFrame {
border: none;
padding: 0;
margin: 0;
background-color: pink;
height: 100%;
}
(注意:有人問之前,#container { position: absolute }
是必要的佈局的原因;我不能改變這種情況。)
你可以看到它在這個小提琴上「工作」:http://jsfiddle.net/9q7yp/
目標是擺脫沿着頁面底部的白色條紋(即,結果中不應該有垂直滾動條)。如果我爲#content
設置overflow: hidden
,那麼問題就會消失。如果有必要,我很樂意做到這一點,但我不能爲了我的生活找出爲什麼沒有這個工作就無法工作。誰能告訴我爲什麼?
做得很好:-)現在,如果你能解釋發生了什麼,我會很樂意接受你的答案。 – FixMaker
@Lorax查看我更新的帖子:) – Passerby
優秀的,全面的描述。謝謝。 – FixMaker