gpt4 book ai didi

html - 如何去除顶部的空白

转载 作者:太空宇宙 更新时间:2023-11-04 15:00:16 24 4
gpt4 key购买 nike

我正在尝试在 materializecss 中的导航栏上方创建顶级超大屏幕这是我的 template.php 代码:

<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
<link rel="stylesheet" type="text/css" href="includes.css"/>

<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>

<div class="top">
<h1>Hello Sykox</h1>
</div>


<nav>
<div class="nav-wrapper">
<a href="#" class="brand-logo">Logo</a>
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li><a href="sass.html">Sass</a></li>
<li><a href="badges.html">Components</a></li>
<li><a href="collapsible.html">JavaScript</a></li>
</ul>
</div>

这是 includes.css 的代码

.top {
height: 170px;
background-color: #ef9a9a;
margin: 0px;

不幸的是,在最顶部出现了空白,即使有 margin: 0px,它也不会消失;或 margin-top:0px;

enter image description here

所以知道如何删除它吗?

最佳答案

试试这个:

<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
<style>
html, body, h1, h2, h3, h4, h5, h6, div {
padding: 0;
border: 0;
margin: 0;
}
.top {
padding: 0;
height: 170px;
background-color: #ef9a9a;
margin: 0px;
}
</style>

<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>

<div class="top">
<h1>Hello Sykox</h1>
</div>


<nav>
<div class="nav-wrapper">
<a href="#" class="brand-logo">Logo</a>
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li><a href="sass.html">Sass</a></li>
<li><a href="badges.html">Components</a></li>
<li><a href="collapsible.html">JavaScript</a></li>
</ul>
</div>

解释:
每个浏览器都有自己的偏好,例如当我在 Chrome 上尝试时,边距设置为 8 px,要覆盖浏览器设置,您需要将其添加到您的 css 中:

html, body, h1, h2, h3, h4, h5, h6, div {
padding: 0;
border: 0;
margin: 0;
}

关于html - 如何去除顶部的空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35285301/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com