【问题标题】:Want to make a background png with a bootstrap navbar, but it won't work想用引导导航栏制作背景png,但它不起作用
【发布时间】:2020-10-21 00:54:20
【问题描述】:

我想为导航栏制作背景图片。此时,它看起来像this

导航栏会随着网站滚动,但有时会很暗,因此您看不太清楚。所以我想为此添加一个背景,但这也不起作用。这是我正在使用的代码...

.nav {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  padding-left: 0;
  margin-bottom: 0;
  list-style: none;
  font-size: 25px;
  background-image: url("img/navbar_background");
  /* (that wont work) */
  z-index: 1;
  position: fixed
}
<nav class="nav">
  <img src="img/marco_d_word_logo.svg" class="logo-image nav-link">
  <a class="nav-link" href=".ueber_mich">Über mich</a>
  <a class="nav-link" href="#">Meine Arbeit</a>
  <a class="nav-link" href="#">Kontakt</a>
  <a class="nav-link" href="#">Impressum</a>
</nav>

【问题讨论】:

  • 你的文件路径正常吗?您是否在开发工具的源面板中看到请求的图像?将 .png 添加到路径中
  • 您缺少图片的扩展名。
  • 我需要什么扩展?
  • 是的,我看到它正在被请求

标签: html css navbar nav


【解决方案1】:

不要忘记写图片的扩展名:

.nav{
   background: url("img/navbar_background.png") no-repeat;
   background-size: 100% 100%; // to fit the image to the nav
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-23
    相关资源
    最近更新 更多