首页 > 解决方案 > 删除 HTML 文档中的边框间隙

问题描述

我正在学习 HTML,并且我创建了一个带有标题栏的非常简单的页面,但是由于某种原因,标题与页面的侧面和顶部之间存在间隙,如下图所示:

在此处输入图像描述

有没有办法删除这个?代码:`<!doctype html>

<style>

    html {
        background: url('background.jpg') no-repeat center center fixed;
        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
        background-size: cover;
    }

    ul {
        list-style-type: none;
        margin: 0;
        padding-top: 10px;
        padding-left: 800px;
        overflow: hidden;
        background-color: rgba(0,0,0,.3);
    }

    li {
        float: left;
    }

    li a {
        display: block;
        color: grey;
        text-align: center;
        padding: 14px 24px;
        text-decoration: none;
        font-size: 20px;
        font-weight: lighter;
        font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif;
    }

    /* Change the link color to #111 (black) on hover */
    li a:hover {
        background-color: #111;
    }


</style>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<ul>
    <li><a href="default">Home</a></li>
    <li><a href="portfolio">Portfolio</a></li>
    <li><a href="contact">Contact</a></li>
</ul>
`

标签: htmlcssborder

解决方案


将此添加到您的 CSS

*{
  margin: 0;
  padding: 0
}


推荐阅读