简体   繁体   English

我的网站顶部有一个缺口

[英]There is a gap at the top of my website

Here is the problem Here is the css Ok so I want to create a simple portfolio website and I am a bit of a novice with HTML and CSS. 这是问题所在 这是css好吧,所以我想创建一个简单的投资组合网站,而我对HTML和CSS还是一个新手。

    <body>

    <header>

        <h1>Sai Daniels</h1>

    </header>

</body>

That's my HTML and my CSS 那是我的HTML和CSS

   @import
    url('https://fonts.googleapis.com/css?family=Raleway:300,400,700,900');
    body{
    font-family: "Raleway";
    padding: 0;
    margin: 0;
    }

    /** HEADER **/
    header{

    color: #00ff6c;
    text-align: center;
    background-color: #232323;
    height: 1000px;

    }

Even on other questions the answers don't help 即使是其他问题,答案也无济于事

I've noticed if I do this it fixes the problem 我注意到如果我这样做可以解决问题

*{
    margin:0;
    padding:0;
}

The problem is that I'm the only one that has to do this and I've been told doing that can lead to problems. 问题是我是唯一必须这样做的人,而且有人告诉我这样做会导致问题。

Use this in css 在CSS中使用它

h1 {
    margin-top: 0;
}

The h1 tag has margin by default by many browsers, such as Google Chrome: 默认情况下, h1标签在许多浏览器(例如Google Chrome)中具有边距:

在此处输入图片说明

Your code overrides the user agent styles, which is why it works. 您的代码将覆盖用户代理样式,这就是它起作用的原因。

I normally use the following code as a quick normalize CSS: 我通常使用以下代码作为快速规范化CSS:

* {
  box-sizing: border-box;
  margin:0;
  padding:0;
}

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

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