html - 如何在背景顶部添加导航栏?

标签 html css

我目前正在创建一个网页,我想在顶部放置一个导航栏,但出于某种原因,即使我在我的 CSS 中将其颜色设置为黑色,它也没有显示。我需要标题“JG.OFFICIAL”在导航内,因为它有 Logo 。但它似乎效果不佳,欢迎提供一些建议。

我的网站:https://jgofficial1.000webhostapp.com/index.html

这是我的代码:

h1 {
  color: white;
  font-family: 'Montserrat', sans-serif;
  height: 40px;
  width: 70px;
}
  body {
  background-image: url("../images/hello.jpg");
  background-size: cover;
  position: fixed;
}
nav {
  color: black;
  height: 60px;
  width: 100%;
}
<link href="https://fonts.googleapis.com/css?family=Montserrat:600" rel="stylesheet">

<nav>
    <div class="header-logo">
        <h1>JG.OFFICIAL</h1>
    </div>
    <ul>
        <li><a href="index.html">HOME</a>
        </li>
        <li><a href="work.html">WORK</a>
        </li>
    </ul>
</nav>

<h2>There's Still a bit of work to be done, come back soon</h2>

最佳答案

如果这就是您要查找的内容,您应该在 nav 中声明 background: black;

关于html - 如何在背景顶部添加导航栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47753078/

相关文章:

html - 图像旁边奇怪的跨度对齐

jquery - 打开模式时如何选择被阻止的内容?

jquery - 如果硬件加速不可用,CSS3 过渡 vs. jQuery 动画?

javascript - 表格宽度超过容器 div

html - 无法将 div 粘贴到他父 div 的底部

CSS部分自动调整高度?

jquery - 从具有相同类别的图像中获取不同的高度和宽度并将其应用于它们的 sibling

javascript - :not() in various guises isn't working

css - 六边形图案不适用于 ems?

css - 一种在移动设备上隐藏标签但显示包含的 div 的方法