我正在构建一个网站,其中主要内容框架应该跨越页面的整个宽度,以及尽可能多的高度,并且具有最小高度(为了包含浮动“侧边栏”)。但是,将div元素的宽度设置为100%并不能填满窗口,它会对其填充,从而创建一个水平滚动条。有没有什么办法可以将内容div拉伸到页面的整个宽度,并且不会从侧面或底部剪切,就像使用框大小或溢出设置一样?CSS - 使用div填充页面(horzonal)
谢谢您的时间, 蒂莫西S.
base.css
html, body {
margin:0;
padding:0;
font-family: "Lucida Grande", Verdana;
font-size: 0.9em;
background-color:#4D714D;
background-image:url("images/titlebar.png");
background-attachment:fixed;
background-repeat:no-repeat;
background-position:0px 7px;
}
div.content
{
position:relative;
top: 150px;
padding: 20px;
margin-left: auto;
margin-right: auto;
width:100%;
min-height:500px;
background-color:#8BB88B;
}
div.sidebar
{
float:right;
position:relative;
top:-20px;
left:20px;
width: 400px;
height: 400px;
background-color:#FFFFFF;
}
例如页面
<html>
<head>
<title>Login</title>
<link type="text/css" href="base.css" rel="stylesheet" />
</head>
<body>
<div class="content">
<div class="sidebar"></div>
<form action="loginScript.php" method="post">
<label>Username:</label>
<input type="text" name="username" /> <br />
<label>Password:</label>
<input type="password" name="password" /> <br />
<input type="submit" value="Login" name="login" />
</form>
<?php print($_GET['msg']) ?>
</div>
</body>
</html>
啊,非常感谢 - 现在做了一些修整。 –