【发布时间】:2022-06-11 00:16:52
【问题描述】:
我是 CSS 和 HTML 的新手,并且在 CSS 中设置了 div,如下所示:
#topBar {
margin-top: 0;
height: 100px;
width: 100%
}
#sideBar {
width: 50px;
margin-left: 0;
margin-top: 100px;
height: 100%;
}
#main {
margin-left: 50px;
margin-top: 100px;
margin-bottom: 50px;
}
#footer {
margin-bottom: 0;
width: 100%;
}
<div id="container">
<div id="topbar" />
<div id="sidebar" />
<div id="main" />
<div id="footer" />
</div>
但这看起来不像我想要的那样。它为每个 div 留出空间,即使它们的空间限制为 x 宽度和 x 高度。
如何将 div 设置为所需的外观?即在 CSS 中有页脚、主栏、侧边栏和顶栏?
【问题讨论】: