简体   繁体   English

如何删除导航栏中徽标和列表项之间的空间?

[英]How to delete this space between the logo and list items in the nav bar?

I want the navigation bar items to align left next to the logo, but am unable to achieve this.我希望导航栏项目在徽标旁边左对齐,但我无法实现这一点。

Does anyone know what is going on?有谁知道发生了什么?

What it looks like:它看起来像什么: 原样

The space I want gone:我想要的空间: 成为

My HTML code:我的 HTML 代码:

<nav id="nav-bar">

<a href=""><img src="https://assets.codepen.io/7471668/logo+pic.png" id="header-img" alt="company-logo" /></a>

<ul class="nav__menu">
  <li class="nav__item">
    <a class="nav-link" href="">Options</a></li>
  <li class="nav__item">
    <a class="nav-link" href="">How it works</a></li>
  <li class="nav__item">
    <a class="nav-link" href="">Sign-up</a></li
</ul>
  
</nav>

My CSS:我的 CSS:

#nav-bar {
  display: flex;
  position: fixed;
  left: 0;
  width: 100%;
  background-color: rgba(0, 0, 0, 1);
  }
.nav__menu {
  display: flex;
  font-size: 0.95rem;
  }
.nav__item {
  margin-right: 3rem;
  font-family: archivo;
  }
.nav-link {
  color: white;
  text-decoration: none;
  }
.nav-link:hover,
.nav-link:focus-visible {
  box-shadow: 0 4px 0 -1px #FFF;
  }
#header-img {
  width: 25%;
  margin-top: 6px;
  margin-left: 10px;
  margin-right: 0;
  }

 #nav-bar { display: flex; position: fixed; left: 0; width: 100%; background-color: rgba(0, 0, 0, 1); }.nav__menu { display: flex; font-size: 0.95rem; }.nav__item { margin-right: 3rem; font-family: archivo; }.nav-link { color: white; text-decoration: none; }.nav-link:hover, .nav-link:focus-visible { box-shadow: 0 4px 0 -1px #FFF; } #header-img { /* from width:25% */ width: 100px; /*Use px*/ margin-top: 6px; margin-left: 10px; margin-right: 0; }
 <nav id="nav-bar"> <a href=""><img src="https://assets.codepen.io/7471668/logo+pic.png" id="header-img" alt="company-logo" /></a> <ul class="nav__menu"> <li class="nav__item"> <a class="nav-link" href="">Options</a></li> <li class="nav__item"> <a class="nav-link" href="">How it works</a></li> <li class="nav__item"> <a class="nav-link" href="">Sign-up</a></li </ul> </nav>
I provided a snippet please do check if it is the output you are looking for. 我提供了一个片段,请检查它是否是您正在寻找的 output。

Simply use "px" to resize the width of your image.只需使用“px”来调整图像的宽度。 I changed width: 25%;我改变了width: 25%; to width: 100px;width: 100px;

width: 25% on #header-img looks like the culprit. #header-img上的width: 25%看起来像是罪魁祸首。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM