Space between Logo Header and Navigation Bar

Recently, I attempted to create a new header with a responsive logo and menu. After seeking guidance from StackOverflow experts, everything seems to be functioning correctly now.

However, I am facing an issue regarding the gap between the header and navbar, as shown in the attached image.

I have tried using margin-bottom, vertical-align, and position properties to fix this gap, but none of them seem to be working.

function myFunction() {
  var x = document.getElementById("nav");

  console.log(barIcon)
  if (x.className === "navbar") {
    x.className += " responsive";
    var barIcon = document.getElementsByClassName('fa-bars')[0];
    barIcon.classList.add("fa-times");
    barIcon.classList.remove("fa-bars");
  } else {
    var closeIcon = document.getElementsByClassName('fa-times')[0];
    closeIcon.classList.remove("fa-times");
    closeIcon.classList.add("fa-bars");
    x.className = "navbar";
  }
}
#logo {
  background: transparent url("images/airlineshq-logo.jpg") no-repeat scroll 0% 0%;
  width: 1040px;
  height: 160px;
  border: 0;
  margin-bottom: 0;
}

@media only screen and (max-width: 600px) {
  #logo {
    width: 100%;
  }
}

.navbar {
  overflow: hidden;
  background-color: #0000ff;
}

.navbar a {
  float: left;
  display: block;
  color: white;
  text-align: center;
  padding: 14px 14px;
  text-decoration: none;
  font-size: 17px;
  height: 18px;
}

.active {
  background-color: #0033CC;
  color: white;
}

.navbar .icon {
  display: none;
}

.navbar a:hover,
input:hover {
  background-color: #dddddd;
  color: black;
}


/* CSS for search box */

.navbar .search-box {
  float: right;
  position: relative;
  margin-top: 3px;
  padding-right: 30px;
  display: flex;
}

.navbar .search-box input {
  padding: 12px;
  border: none;
  width: 100%;
  height: 100%;
  padding: 10px;
}

.navbar .search-box button {
  color: #999;
  border: navajowhite;
  padding: 10px;
}

@media screen and (max-width: 600px) {
  .navbar a,
  .navbar .search-box,
  .navbar .search-icon {
    display: none;
  }
  .navbar a.icon {
    float: left;
    display: block;
  }
}

@media screen and (max-width: 600px) {
  .navbar.responsive {
    position: relative;
  }
  .navbar.responsive .icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  .navbar.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
  .navbar.responsive .search-box {
    float: none;
    display: flex;
    width: 90%;
    padding: 4%;
    border: 2px solid black;
  }
  .navbar.responsive .search-icon {
    display: flex;
  }
}
<div class="content">
  <header id="logo"></header>
  <div class="navbar" id="nav">
    <a href="https://klia2.co" class="active">Home</a>
    <a href="../facilities/index.htm">Facilities</a>
    <a href="../airlines/index.htm">Airlines Offices</a>
    <form class="search-box">
      <input type="text" placeholder="Search..">
      <button type="submit" class="search-icon"><i class="fa fa-search"></i></button>
    </form>
    <a href="javascript:void(0);" class="icon" onclick="myFunction()"><i class="fa fa-bars"></i></a>
  </div>

Answer №1

Upon executing the code snippet, I noticed that there is no space between the <header> and the

<div class="navbar">
.

The styling of the header element in #logo includes a specific height: 160px;, which may create the appearance of a gap even though it is simply following the designated height requirement of 160px.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Employing PHP conditions alongside JavaScript to conceal the div elements

I have been struggling with a problem for the past few hours and still haven't found a solution. I am new to php. What I am trying to achieve is to display and hide a div based on a PHP condition. Here is the scenario: Please note: By default, the DI ...

Persistent footer overlaps lower body content

Issue with Sticky Footer in Safari I recently added a sticky footer to my website, but I'm facing problems with it covering the body content on Safari. It works fine on Chrome and Firefox after adding a bottom margin to the body to adjust for the hei ...

Issues with custom logo and menu/sidebar toggle on Wordpress

Hello everyone, I am currently facing some difficulties with my new WordPress blog that utilizes the Skilt-Theme. Specifically, I'm having trouble with the custom-logo and sidebar-toggle features. When there is no logo present, you can see the layout ...

Alignment of headers and footers in email newsletters for various email clients<td>

With my limited coding skills, I've been struggling to keep the header and footer aligned properly in all email clients. The footer consistently displays a 1 px gap between elements, which causes it to move around unpredictably. Here's the full s ...

Using a personalized font in your RShiny application

I'm interested in integrating a unique custom font into my Rshiny App. I have a feeling that the necessary code should be placed within tags$style, but I am unsure of the exact syntax needed for this integration. Below is an example code snippet: ui ...

Comparison of getComputedStyle() and cssText functionality between Internet Explorer and Firefox

Take a look at this example to see the issue in action. I'm attempting to access the cssText property of a <div> using window.getComputedStyle(element) (which provides a CSSStyleDeclaration object). While this works smoothly in Chrome, it' ...

Displaying JavaScript array contents in an HTML page without using the .innerHTML property

As someone new to the world of JavaScript and web development, I find myself faced with a challenge. I want to showcase the contents of two different JavaScript arrays in an HTML format. However, my research has led me to believe that utilizing .innerHTML ...

Allow users to zoom in and out on a specific section of the website similar to how it works on Google Maps

I am looking to implement a feature on my website similar to Google Maps. I want the top bar and side bars to remain fixed regardless of scrolling, whether using the normal scroll wheel or CTRL + scroll wheel. However, I would like the central part of the ...

Having trouble with the basic function of jQuery radio buttons, unable to make them work properly

Struggling with my first attempt at incorporating jQuery into my project. I have set up 2 radio buttons on a form, and I want the selected option to update the value of an input text box within the same form. However, despite my best efforts, I just can&ap ...

Tips for detecting if text appears in bold on a webpage using Selenium

I came across a pdf document with the following content: <div class=**"cs6C976429"** style="width:671px;height:18px;line-height:17px;margin-top:98px;margin-left:94px;position:absolute;text-align:left;vertical-align:top;"> <nobr ...

Generate a new array using a single value extracted from an existing array

I'm new to working with arrays. Before this, I used to manually code everything in HTML. My question is, can you create an array based on the values of another array? var pmmain =["aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", ...

What is the method for including preset text within a search bar?

My current issue is as follows: When the searchbox is focused, it appears like this: -------------------- -------------------- Upon exiting the searchbox, a string will automatically be added to it: -------------------- Search -------------------- I a ...

Is it feasible to utilize the translate function twice on a single element?

Using Javascript, I successfully translated a circle from the center of the canvas to the upper left. Now, my aim is to create a function that randomly selects coordinates within the canvas and translates the object accordingly. However, I'm encounter ...

Well, it appears that I am having trouble establishing a connection between the users in this chatting application

I'm encountering a problem with establishing a connection between two users. I have already installed express and socket.io, but for some reason, the message is not getting through to the receiver's end. The code seems to be running fine as I can ...

Shift the Search bar to the last position on the navigation bar

I'm looking to relocate the search icon and input field to the end of the navbar. I'm currently using Bootstrap 5.0.2, but I am still new to Bootstrap, HTML, and CSS, so I'm not sure how to accomplish this. I want the width of the search box ...

The value of "asp-route-id" is dynamically determined through the use of

Hey there, I’m looking to dynamically pass a value from "codeDrink" to my controller using "asp-route-id" and Ajax in my ASP.NET MVC project. This is how I am handling it in my view: <p> <a id="deleteLink" asp-action="Delete& ...

Hovering over an element will change its background color along with adjusting the background

I encountered a situation with the following code: CSS: <style> div.testy { border:1px solid black; } div.testy:hover { background-color:red; } </style> HTML: <div class="testy" style="height:100px; back ...

What exactly is Bootstrap - a CSS framework, a JavaScript framework, or a combination

Being new to Bootstrap, I have taken the time to explore What is Bootstrap? as well as http://getbootstrap.com/. From what I understand so far, Bootstrap is a CSS framework that aids in creating responsive designs that can adapt to various devices. Essent ...

What is the sequence in which the browser handles CSS?

I have a specific class that is being styled in multiple places on my website. I am curious about the order in which the browser reads and applies these different styles. Can you explain this process to me? Inline Style <div class="yellowtag" sty ...

Tips for making a screen adapt to different monitor resolutions

Hello there! I've been working on a login screen using bootstrap 4, but I'm facing an issue with the layout. My concern is about adjusting the page layout so that the background image does not get cut off or distorted. Take a look at the image ...