我试图让主要内容区域和边栏具有相同的背景和相同的高度。我认为如果我在同一个 <div>
中的两个子类会起作用,但显然它不起作用。有没有一种简单的方法可以实现这一点,还是我必须使用一些虚假的列技巧?
HTML:
<body>
<div id="wrapper">
<div id="header">
<h1>Page title</h1>
<h3>Subtitle</h3>
</div>
<div id="main">
<div class="content">This is the main area</div>
<div class="sidebar">This is the sidebar</div>
</div>
<div id="footer">
The footer;
</div>
</div>
</body>
</html>
CSS:
body {
margin: 0;
padding: 0;
background-color: #ff1;
}
#wrapper {
width: 800px;
margin: 0 auto;
}
#header {
background-color: rgba(255,255,255,0.7);
}
#nav {
background-color: rgba(255,255,255,0.7);
}
#main {
background-color: rgba(255,255,255,0.7);
}
.content, .sidebar {
float: left;
padding: 20px;
}
.content {
width: 510px;
}
.sidebar {
width: 210px;
}
#footer {
background-color: rgba(255,255,255,0.7);
clear:both;
}
最佳答案
关于html - 为两列获取相同的背景和长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21351471/