简体   繁体   English

页眉和页脚有白色边框吗?

[英]Header and footer have a white border?

I know question like this get asked all the time and I apologize for asking again, but I can't seem to figure this out by myself. 我知道这样的问题一直被问到,我很抱歉再次提出问题,但我似乎无法自己弄清楚。 I'm trying to add a header and footer and I finally made it so they are positioned correctly, but they don't fill the entire area and are surrounded by white. 我试图添加页眉和页脚,但最终使它们正确放置,但它们不能填满整个区域并被白色包围。 How can I fix this? 我怎样才能解决这个问题?

https://codepen.io/jaydotxxx/pen/yOvLyv https://codepen.io/jaydotxxx/pen/yOvLyv

# container {
  margin: 0 auto;
  padding:40px;
}

#header {
  z-index:0;

    height: 30px;
    background-color: black;
}
#footer {
  z-index:2;
    height: 30px;
    width:100%;
    padding:0px;
    position: relative;
    bottom: 0;
    background-color: black;
}
#image {
  z-index:1;
  height:1000px;
  width:100px;
  margin:20px auto;

  padding:50px;
  background-color:red;

}

I think you are looking for something like: 我认为您正在寻找类似的东西:

body {
  margin: 0;
}

Just as a general HTML/CSS tip related to what you're asking, a lot of web developers put: 正如与您所要求的内容有关的一般HTML / CSS技巧一样,许多Web开发人员都提出:

* {
     margin: 0;
     padding: 0;
}

at the top of their main css file, which causes the browser to clear all default paddings and margins (which are arbitrary, set by the vendors) so as to make their pages appear the same in every browser. 在其主要css文件的顶部,这将导致浏览器清除所有默认的填充和边距(由供应商设置,它们是任意的),以使它们的页面在每个浏览器中都一样。 Obviously, you will need to tweak some things to your liking later. 显然,您稍后需要根据自己的喜好调整一些内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM