gpt4 book ai didi

html - 从我的导航栏中删除空格

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

这是我的代码(我完全是 html 菜鸟)这段代码在我的导航顶部和左侧给我留了空白...你们知道我做错了什么吗?

    div.nav {
background-color: black;
color: white;
font-size: 20px;
font-weight: bold;
position: fixed;
width: 100%;
text-align: center;
}
ul {

}
li {
display: inline-block;
list-style: none;
}
li a {
padding: 15px;
color: white;
}


<div class="nav">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="watisdb.html">Wat is D&B</a></li>
<li><a href="dbnederland.html">D&B in Nederland</a></li>
</ul>
</div>

添加了 html

最佳答案

这是 CSS。添加这个

body{
padding: 0;
margin: 0;
}

body{
padding: 0;
margin: 0;

background-color: #e8e4e5;
}
div.nav {
background-color: black;
color: white;
font-size: 20px;
font-weight: bold;
position: fixed;
width: 100%;
text-align: center;
}
ul {

}
li {
display: inline-block;
list-style: none;
}
li a {
padding: 15px;
color: white;
}
<div class="nav">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="watisdb.html">Wat is D&B</a></li>
<li><a href="dbnederland.html">D&B in Nederland</a></li>
</ul>
</div>

但是您可以将 nav div 位置设置为固定:当您在内容中滚动时它会有所帮助,但 nav div 始终位于顶部。

 body{
padding: 0;
margin: 0;
}
.content{
margin-top: 60px;
height: 150vh;
background-color: #d2d29d;
}
div.nav {
position: fixed;
height: 60px;
background-color: black;
color: white;
font-size: 20px;
font-weight: bold;
position: fixed;
top: 0;
left: 0;
width: 100%;
text-align: center;
}
ul {

}
li {
display: inline-block;
list-style: none;
}
li a {
padding: 15px;
color: white;
}
<div class="nav">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="watisdb.html">Wat is D&B</a></li>
<li><a href="dbnederland.html">D&B in Nederland</a></li>
</ul>
</div>
<div class="content">
Some text
</div>

关于html - 从我的导航栏中删除空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48561872/

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