边距底部不起作用?
由于某种原因,我无法在页面底部添加一些填充。我有一个内容框,它到达页面末尾并到达底部,看起来不太好。我想在页面底部留出一些空间来解决这个问题,但似乎 margin-bottom 没有像我期望的那样工作?我已经包含了以下代码,它应该是影响内容框的所有内容。我尝试删除 html/body 中的 margin:0 (尽管我有点需要),但这似乎也不起作用?我觉得我错过了一些非常明显的东西。
html, body {
margin:0;
padding:0;
width:100%;
height:100%;
text-align:left;}
#content {
position: absolute;
left: 50%;
margin-left: -368px;
top: 104px;
padding-left: 35px;
padding-right: 35px;
padding-top: 15px;
padding-bottom: 15px;
background-color: white;
border: 1px solid black;
width: 664px;
margin-bottom: 20px;}
任何帮助将不胜感激:) 谢谢!
I am having trouble for some reason with getting the bottom of my page to have some padding. I have a content box that goes to the end of the page and hits the bottom and doesn't look the greatest. I want to give some space from the bottom of the page to fix this issue, but it seems that margin-bottom isn't working as I expect it to? I have included the following code which should be everything that affects the content box. I have tried removing the margin:0 in the html/body (even though I kind of need that), but that doesn't seem to work either? I feel like I am missing something really obvious.
html, body {
margin:0;
padding:0;
width:100%;
height:100%;
text-align:left;}
#content {
position: absolute;
left: 50%;
margin-left: -368px;
top: 104px;
padding-left: 35px;
padding-right: 35px;
padding-top: 15px;
padding-bottom: 15px;
background-color: white;
border: 1px solid black;
width: 664px;
margin-bottom: 20px;}
Any help would be greatly appreciated :) Thanks!
Live link - http://quintinmarcus.com/portfolio/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于
content
具有position:absolute
,因此它的后边距不执行任何操作,也不应拉伸正文的内部高度,以便正文的 padding-bottom 执行任何操作。Since
content
hasposition: absolute
, its after margins do nothing, nor should it stretch the inner height of the body so that the body's padding-bottom does anything.如果您想要将布局居中,请将
#content
当前样式修改为以下内容:CSS:
这还将使您能够在所需的底部留出边距。
If you want to centre your layout, modify your current style for
#content
to the following:CSS:
This will also enable you to give the margin at the bottom you want.