我想在此之前加上我是一个完整的新手,所以请记住这一点。所以我要做的是有一个主要的内容区域,我想要一个特定的宽度,让我们说800px。在它的左侧和右侧,我只想要一个黑色边框。现在我想要它,所以当有人调整页面大小时,两个边框会改变宽度以填充整个窗口,但我的主要内容框保持不变。无法弄清楚。谢谢你的帮助!
答案 0 :(得分:4)
试试这个:
<html>
<head>
<style>
html {height:100%;}
body {background-color:#000000;height:100%;margin:0px;padding:0px;}
#content{background-color:#FFFFFF;width:800px;margin:auto;height:100%;}
</style>
</head>
<body>
<div id="content">content</div>
</body>
</html>
答案 1 :(得分:1)
如果这是您的HTML代码:
<div id="outer-container">
<div id="main-content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</div>
您可以将CSS设置为以下内容,它应该可以正常工作。
<style type="text/css">
#outer-container {
background-color: black;
height: 200px;
}
#main-content {
background-color: white;
width: 800px;
margin: 0 auto 0 auto;
height: 200px;
}
</style>