我有一个可以根据内容调整大小的页面。我需要的是一种让侧边栏随身体增加/减少的方式,但绝不会低于可见身体的 100%。
最初页面看起来不错,但是当我增加内容时,我可以看到左右两侧下方的空白,而本来应该没有的。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
.container
{
background-color: Gray;
height: 100%;
width: 100%;
position: absolute;
clear: both;
}
.content
{
background-color: white;
width: 80%;
margin: 0 auto;
height: 100%;
min-height: 100%;
}
</style>
<script type="text/javascript" src="js/jquery-latest.js"></script>
<script language="javascript" type="text/javascript">
function MakeBig() {
var html = "";
for (var i = 0; i < 500; i++) {
html += "this is some random filler text<br/>";
}
$("#textHolder").html(html);
}
function MakeSmall() {
var html = "";
for (var i = 0; i < 5; i++) {
html += "this is some random filler text<br/>";
}
$("#textHolder").html(html);
}
</script>
</head>
<body>
<div id="container" class="container">
<div id="content" class="content">
This is some text in the content
<button id="btnMakeBigDiv" onclick="MakeBig()">Increase Content</button><br/>
<button id="btnMakeSmallDiv" onclick="MakeSmall()">Decrease Content</button>
<div id="textHolder"></div>
</div>
</div>
</body>
</html>