<分区>
<分区>
所以我一直致力于为我和我的 friend 制作一个网站,直到现在我已经制作了菜单栏和一个交流空间(使用 <div>
s)。但我似乎没有让第二个 div 出现。我的问题在哪里?为什么不显示?
这是我的代码:
#MenuBar {
width: 100%;
height: 10%;
background-color: blue;
border-radius: 30px;
position: center;
display: fixed;
}
body {
background-color: black;
background-repeat: no-repeat;
}
#MenuTabs {
width: 75%;
height: 75%;
color: white;
position: center;
}
#Messenger {
width: 50%;
height: 50%;
background-color: white;
display: fixed;
}
<!-- The menu tab -->
<div id="MenuBar">
<table id="MenuTabs" cellspacing="1%" align="center">
<tr>
<td>Home</td>
<td>Lessons</td>
<td>Playground</td>
<td>About</td>
</tr>
</table>
</div>
<!-- Communication Tab-->
<div id="Messenger"></div>
如您所见,它只显示菜单栏,但不显示白色背景的 div。你能帮我解决这个问题吗?
最佳答案
第二个 div 没有显示的原因是,您使用的是 %
作为 <div>
的高度秒。使用 %
作为高度,您必须在 %
中应用高度给它所有的 parent 。因此,要使其正常工作,您必须指定 body
的高度。和 html
在 %
.
因此,您还必须将下面给定的样式添加到您的 CSS 中:
html,
body {
height: 100%;
}
关于html - 分区不显示!为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38041504/