我为我的网站创建了一个评论部分,我有一个按钮可以让你编辑你的评论,这会将你重新路由到另一个页面。我设置了边距,因此内容不会隐藏在我的页眉或页脚后面,但现在我似乎无法找到让背景颜色延伸到页面底部的方法。
我弄乱了 css 中的位置,背景颜色确实延伸到页面底部,但随后我的标题消失了。
我的 CSS...
#headerContainer {
margin: -60px 0px 0px 0px;
background-color:#333;
height: 60px;
width: 100%;
position: fixed;
}
.editCommentBody {
margin: 60px 0px 40px 0px;
height: 100%;
text-align: center;
background-color: #ddd;
}
editCommentBody 类是从标题到编辑按钮的所有内容。
最佳答案
您尚未在 headerContainer 样式中为固定位置设置值。
尝试为其提供 left:value 和 top:value 并且,当您使用 positions 时,边距有时不起作用,如果您的边距有效,它有一个 top:-60px 导致您的标题超出屏幕,试试这个:
#headerContainer {
margin:0px;
background-color:#333;
height: 60px;
width: 100%;
position: fixed;
left:0px;
top:0px;
}
关于php - 无论窗口大小如何,我都需要将背景颜色灰色向下移动以覆盖页面的长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55562954/