0
我有一個白色居中的容器DIV應至少100%的窗口的高度,但如果裏面的文本更長,DIV應擴展到適合內容。相反,超出窗口高度的部分文本會進入灰色背景。DIV沒有擴展到內容,如果一些長文本放入它
我嘗試了一些你的建議,我讀過如把min-height
!而非height
S IN的body
,html
和#cntr
,但白色的容器完全消失。將overflow:hidden
添加到#cntr
只是將文本裁剪爲窗口大小,使其部分完全不可見。
這裏是我的代碼(不包括一些CSS,這裏不是特別重要):
<!doctype html>
<html>
<head>
<meta content="charset=UTF-8">
<style type= "text/css">
html{
height:100%;
margin: 0;
}
body {font-family: Georgia; height:99%; margin: 0.25% 0}
div {position: absolute}
#cntr {
width: 1250px;
display: block;
position: relative;
top: 0;
float: none;
margin: 0 auto;
background-color: white;
height:100%;
}
</style>
</head>
<body style="background-color: #708090">
<div id="cntr">
<div style="right: 0; top: 0; width:100%; height: 261px; border-bottom: solid 1px black">
<a href="index.html"><img src= "png/logojan2.png" style="position: absolute; top:55px; left: 240px"></a>
<img src="png/rze.png" style="position: absolute; right: 50px; bottom:24px">
</div>
<div style="top: 300px; left: 50px; height: 60%; width:300px">
<div style="position: fixed; background-color: black; height: inherit; width: inherit">
</div>
</div>
<div style="top:300px; left:400px; width:800px">
/*some long <p>'s of text here*/
</div>
</div>
</body>
</html>
編輯:這裏是向下滾動後的頁面截圖(白色DIV應該延伸到頁面的底部): screenshot
感謝您對我如何解決我的問題提出任何建議。
'