导航栏中的错误-视口顶部的空隙

时间:2019-04-16 16:09:14

标签: html css

我正在重新排列导航栏,在左侧显示图像,在右侧显示链接,并且我对导航栏进行了一些修改。

此错误仅在两页上发生,所以我想也许是因为我附加了不同的CSS文件。我检查了两者的代码,除了正文以外,没有任何空白或边距。 栏也是固定的

我尝试了[导航栏按钮顶部和侧面的间隙] [1],但没有帮助。 提前很抱歉,因为代码很多,感谢您的宝贵时间

 

   * {
      font-family: arial, sans-serif;
      box-sizing: border-box;
    }

    html,
    body {
      margin: 0;
      padding: 0;
    }

    a {
      text-decoration: none;
      color: black;
    }

    .nav-wrapper {
      width: 100%;
      position: fixed;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .nav {
      margin-left: auto;
      background-color: rgba(255, 255, 255, .8);
      border-radius: 0px;
      border: none;
      margin: 0;
      padding: 0;
      display: flex;
    }

    .item {
      color: black;
      font-weight: bold;
      text-transform: uppercase;
      font-size: 15px;
      margin-left: 30px;
      margin-right: 30px;
    }

    .submenu {
      display: none;
      flex-wrap: wrap;
      align-items: center;
      align-text: center;
      position: absolute;
      padding-top: 107px;
      padding: 10px;
      left: 0;
      right: 0;
      text-transform: uppercase;
      z-index: 1;
      background-color: #2F4F4F;
      color: white;
      justify-content: space-evenly;
    }

    .submenu li {
      margin-left: 6%;
      width: 19%;
      padding: 5px;
    }

    .item.has-children:hover .submenu {
      display: flex;
      align-items: center;
      flex-direction: row;
      justify-content: left;
      font-size: 15px;
      flex-wrap: wrap;
      flex: 1 1 calc(25% - 80px);
      color: black;
      background-color: rgba(255, 255, 255, .8);
    }

    ul {
      list-style: none;
      padding: 0;
    }

    * {
      text-align: center;
    }

    body {
      margin-top: 150px;
      color: #7a9ba6;
      font-size: 20px;
    }

    a body {
      color: #90949b;
      font-size: 20px;
      text-decoration: none;
    }

    h1 {
      font-size: 25px;
      color: #415b76;
    }

    .cyan {
      color: cyan;
      background-color: #233656;
      border-radius: 5px;
      padding: 3px;
    }

    .magenta {
      color: magenta;
      background-color: #233656;
      border-radius: 5px;
      padding: 3px;
    }

    .yellow {
      color: yellow;
      background-color: #233656;
      border-radius: 5px;
      padding: 3px;
    }

    .key {
      color: black;
      border-radius: 5px;
      padding: 3px;
    }
    <nav class="nav-wrapper">
      <a href="index.html" style="margin-left: 75px; margin-top: 7px;">
        <img src="../Images/Navigation/Intak Logo 25px High.png" alt="Home" align="left" />
      </a>

      <ul class="nav">
        <li class="item has-children"><a href="Printing.html">Printing</a>
          <!--		<ul class="submenu">
    				<li>Labels & Stickers</li>
    				<li>Banners</li>
    				<li>A-Frame</li>
    				<li>Menu Boards</li>
    				<li>Takeout Menus</li>
    				<li>Business Cards</li>
    				<li>Dine-In Menus</li>
    				<li>Posters</li>
    				<li>Envelopes</li>
    				<li>Chinese Wedding Cards</li>
    				<li>Flyers</li>
    				<li>Letterheads</li>
    				<li>Brochures</li>
    				<li>Vinyl</li>
    				<li>NCR Forms</li>
    				<li>Catalogues</li>
    			</ul> -->
        </li>
        <li class="item has-children"><a href="Graphic Design.html">Graphic Design</a>
          <!--		<ul class="submenu">
    				<li>Logo Design</li>
    				<li>Ads/Flyers/Promotions</li>
    				<li style="text-align: center;">Menu Boards<br>
    					(Digital & Boards)</li>
    				<li style="text-align: center;">Restaurant Menus<br>
    					(Takeout & Dine-In)</li>
    			</ul>-->
        </li>
        <li class="item has-children">Chinese Calendars
          <ul class="submenu">
            <li><a href="Calendars/Cane Wallscroll Calendars.html">Cane Wallscroll Calendars</a></li>
            <li><a href="Calendars/Wall Calendars.html">Wall Calendars</a></li>
            <li><a href="Calendars/Mini Calendars.html">Mini Calendars</a></li>
            <li><a href="Calendars/Desk Calendars.html">Desk Calendars</a></li>
            <li><a href="Calendars/Special Desk Calendars.html">Special Desk Calendars</a></li>
            <li><a href="Calendars/Red Packet.html">Red Packet</a></li>
            <li><a href="Calendars/More.html">More Calendars</a></li>
          </ul>
        </li>
        <li class="item" style="color: #4D4D4D;">FAQS</li>
        <li class="item"><a href="Contact Us.html">Contact Us</a></li>
      </ul>
    </nav>

    <body>

      <h1>What is offset printing?</h1>

      Offset printing refer to lithography in general. Which produce the highest quality output of any printing process available today.<br> Because of the fragility nature of the printing plate used in lithography, the process is best suit for short to medium
      run jobs.

      <h1>What is PMS?</h1>

      Pantone Matching System (PMS) is a standard set of color palette that was created to allow a way to describe a color.<br> For more information, see <a href="www.pantone.com" style="color: #4D4D4D;">www.pantone.com</a>.

      <h1>What is process colors?</h1>

      Process colors are <span class="cyan">Cyan</span>, <span class="magenta">Magenta</span>, <span class="yellow">Yellow</span> and <span class="key">Black</span>.<br> By overlapping dot patterns in those 4 colors, about 70% of all the visible colors can
      be reproduce.

      <h1>What is color matching?</h1>

      Since every monitor, graphic card, printer have their own characteristic when displaying color, the colors may look very different in different system.<br> In order to counter those short coming, color matching software is used to calibrate input/output
      devises like monitor, scanner, printer etc...<br> For more information, see <a href="www.datacolor.com" style="color: #4D4D4D;">www.datacolor.com</a>.

      <h1>How to send graphic files?</h1>

      We accept files in Press Quality PDF format (Hi-Res, CMYK).<br> Make sure you embed all fonts and graphics file you used with your document. A hardcopy print out would be very helpful.

  [1]: https://stackoverflow.com/questions/49276641/gaps-at-the-top-and-side-of-navigation-bar-buttons

4 个答案:

答案 0 :(得分:2)

我可以看到页边距为150px的正文;

body {
    margin-top: 150px;
    color: #7a9ba6;
    font-size: 20px;
}

可能是问题

答案 1 :(得分:2)

我不确定我是否清楚地了解您想要实现什么。

如果要一直将导航栏固定在顶部。您可以将top: 0放到具有.nav-wrapper的{​​{1}}上,否则将其设置在与其父项(拥有{{1}的position: fixed)相同的位置}

https://codepen.io/krugtep/pen/GLyvLW

答案 2 :(得分:2)

CSharpScript.EvaluateAsync
delegate

 

   * {
      font-family: arial, sans-serif;
      box-sizing: border-box;
    }

    html,
    body {
      margin: 0;
      padding: 0;
    }

    a {
      text-decoration: none;
      color: black;
    }

    .nav-wrapper {
      width: 100%;
      position: fixed;
      display: flex;
      top: 0;
      align-items: center;
      justify-content: space-between;
    }

    .nav {
      margin-left: auto;
      background-color: rgba(255, 255, 255, .8);
      border-radius: 0px;
      border: none;
      margin: 0;
      padding: 0;
      display: flex;
    }

    .item {
      color: black;
      font-weight: bold;
      text-transform: uppercase;
      font-size: 15px;
      margin-left: 30px;
      margin-right: 30px;
    }

    .submenu {
      display: none;
      flex-wrap: wrap;
      align-items: center;
      align-text: center;
      position: absolute;
      padding-top: 107px;
      padding: 10px;
      left: 0;
      right: 0;
      text-transform: uppercase;
      z-index: 1;
      background-color: #2F4F4F;
      color: white;
      justify-content: space-evenly;
    }

    .submenu li {
      margin-left: 6%;
      width: 19%;
      padding: 5px;
    }

    .item.has-children:hover .submenu {
      display: flex;
      align-items: center;
      flex-direction: row;
      justify-content: left;
      font-size: 15px;
      flex-wrap: wrap;
      flex: 1 1 calc(25% - 80px);
      color: black;
      background-color: rgba(255, 255, 255, .8);
    }

    ul {
      list-style: none;
      padding: 0;
    }

    * {
      text-align: center;
    }

    body {
      margin-top: 150px;
      color: #7a9ba6;
      font-size: 20px;
    }

    a body {
      color: #90949b;
      font-size: 20px;
      text-decoration: none;
    }

    h1 {
      font-size: 25px;
      color: #415b76;
    }

    .cyan {
      color: cyan;
      background-color: #233656;
      border-radius: 5px;
      padding: 3px;
    }

    .magenta {
      color: magenta;
      background-color: #233656;
      border-radius: 5px;
      padding: 3px;
    }

    .yellow {
      color: yellow;
      background-color: #233656;
      border-radius: 5px;
      padding: 3px;
    }

    .key {
      color: black;
      border-radius: 5px;
      padding: 3px;
    }

只需将 <nav class="nav-wrapper"> <a href="index.html" style="margin-left: 75px; margin-top: 7px;"> <img src="../Images/Navigation/Intak Logo 25px High.png" alt="Home" align="left" /> </a> <ul class="nav"> <li class="item has-children"><a href="Printing.html">Printing</a> <!-- <ul class="submenu"> <li>Labels & Stickers</li> <li>Banners</li> <li>A-Frame</li> <li>Menu Boards</li> <li>Takeout Menus</li> <li>Business Cards</li> <li>Dine-In Menus</li> <li>Posters</li> <li>Envelopes</li> <li>Chinese Wedding Cards</li> <li>Flyers</li> <li>Letterheads</li> <li>Brochures</li> <li>Vinyl</li> <li>NCR Forms</li> <li>Catalogues</li> </ul> --> </li> <li class="item has-children"><a href="Graphic Design.html">Graphic Design</a> <!-- <ul class="submenu"> <li>Logo Design</li> <li>Ads/Flyers/Promotions</li> <li style="text-align: center;">Menu Boards<br> (Digital & Boards)</li> <li style="text-align: center;">Restaurant Menus<br> (Takeout & Dine-In)</li> </ul>--> </li> <li class="item has-children">Chinese Calendars <ul class="submenu"> <li><a href="Calendars/Cane Wallscroll Calendars.html">Cane Wallscroll Calendars</a></li> <li><a href="Calendars/Wall Calendars.html">Wall Calendars</a></li> <li><a href="Calendars/Mini Calendars.html">Mini Calendars</a></li> <li><a href="Calendars/Desk Calendars.html">Desk Calendars</a></li> <li><a href="Calendars/Special Desk Calendars.html">Special Desk Calendars</a></li> <li><a href="Calendars/Red Packet.html">Red Packet</a></li> <li><a href="Calendars/More.html">More Calendars</a></li> </ul> </li> <li class="item" style="color: #4D4D4D;">FAQS</li> <li class="item"><a href="Contact Us.html">Contact Us</a></li> </ul> </nav> <body> <h1>What is offset printing?</h1> Offset printing refer to lithography in general. Which produce the highest quality output of any printing process available today.<br> Because of the fragility nature of the printing plate used in lithography, the process is best suit for short to medium run jobs. <h1>What is PMS?</h1> Pantone Matching System (PMS) is a standard set of color palette that was created to allow a way to describe a color.<br> For more information, see <a href="www.pantone.com" style="color: #4D4D4D;">www.pantone.com</a>. <h1>What is process colors?</h1> Process colors are <span class="cyan">Cyan</span>, <span class="magenta">Magenta</span>, <span class="yellow">Yellow</span> and <span class="key">Black</span>.<br> By overlapping dot patterns in those 4 colors, about 70% of all the visible colors can be reproduce. <h1>What is color matching?</h1> Since every monitor, graphic card, printer have their own characteristic when displaying color, the colors may look very different in different system.<br> In order to counter those short coming, color matching software is used to calibrate input/output devises like monitor, scanner, printer etc...<br> For more information, see <a href="www.datacolor.com" style="color: #4D4D4D;">www.datacolor.com</a>. <h1>How to send graphic files?</h1> We accept files in Press Quality PDF format (Hi-Res, CMYK).<br> Make sure you embed all fonts and graphics file you used with your document. A hardcopy print out would be very helpful.添加到`.nav-wrapper 在这里看起来不错。差距消失了

答案 3 :(得分:1)

导航是身体的一个子代,因此即使位置:固定;您必须设置顶部:75像素或您希望元素距页面顶部的距离。否则,它会受到顶部边缘的影响。