Experiencing an unappealing space between my Navbar and Header Background graphic

I encountered an issue with using flexbox for my header background image and Navigation Bar - there seems to be a gap between the two components.

Screenshot

HTML:

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Real Estate</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body style="background-color: #e3e3e3;">   
    <div class="headercontainer">
            <img src="images/manifestspace.png" style="width: 30vw; margin-bottom: 10vw;">
            <img src="images/welcomehome.png" style="width: 50vw; margin-bottom: 1vw;">
            <img src="images/buysell.png" style="width: 50vw;">
        
    </div>
    <main>
        <nav>
            <ul>
                <li><a href="#Owners">Owners</a></li>
                <!-- <li><a href="#Properties">Properties</a></li> -->
                <li><a href="#Property-Managers">Property-Managers</a></li>
                <li><a href="#Tenants">Tenants</a></li>
                <li><a href="#Maintanence">Maintenance</a></li>
            </ul>
        </nav>
    </main>
</body>
</html>

CSS:

.headercontainer {
  display: flex;
  align-items: center;
  flex-direction: column;
  background-image: url("https://static.wixstatic.com/media/062482_377883e1ce2a449aba2c775b8f57027b~mv2.jpeg/v1/fill/w_1215,h_810,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/062482_377883e1ce2a449aba2c775b8f57027b~mv2.jpeg");
  height: 35vw;
  background-repeat: repeat-x;
  background-size: cover;
  background-position: center;
  /* row-gap: 4vw; */
}
body {
  margin: 0;
}

nav ul {
  background-color: #181919;
  list-style: none;
  display: flex;
  flex-direction: row;
  justify-content: flex;
  padding: 15px;
  justify-content: space-evenly;
}
nav ul li a {
  text-decoration: none;
  color: white;
  padding: 0 10px;
}

I have checked for any padding or margins causing the gap but couldn't find anything obvious. Any assistance in resolving this would be highly appreciated!

Answer №1

For a possible solution, consider implementing the following suggestions:

nav {
  margin-top: 0; /* Feel free to adjust to your desired value */
}

If the above does not resolve the issue, you may want to include the following in your CSS:

main {
  margin-top: 0; /* You can modify this as needed */
}

Answer №2

To adjust the height in your CSS, target the .headercontainer element.

Change height: 35vw; to height: 30vw;

CSS :

.headercontainer {
  display: flex;
  align-items: center;
  flex-direction: column;
  background-image: url("https://static.wixstatic.com/media/062482_377883e1ce2a449aba2c775b8f57027b~mv2.jpeg/v1/fill/w_1215,h_810,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/062482_377883e1ce2a449aba2c775b8f57027b~mv2.jpeg");
  height: 30vw;
  background-repeat: repeat-x;
  background-size: cover;
  background-position: center;
}
body {
  margin: 0;
}

nav ul {
  background-color: #181919;
  list-style: none;
  display: flex;
  flex-direction: row;
  justify-content: flex;
  padding: 15px;
  justify-content: space-evenly;
}
nav ul li a {
  text-decoration: none;
  color: white;
  padding: 0 10px;
}

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

Incorporating fontawesome icons ABOVE custom menu items in WordPress

In the process of customizing a menu in WordPress, I am looking to add fontawesome icons above each list item. In the past, I achieved this using the following code: <ul> <li> <a href="#"> <i class="fa fa-home"></i&g ...

Unique CSS specifically designed for consecutive elements listed in succession

I have a list of notes in a document, but occasionally I may include some document updates (such as "Document closed", "Revision made"...). Here is the basic HTML structure of a document and its notes: <p class="document-note">My note</p> < ...

Pop-up Registration Form Activation Using JQuery

I am attempting to create a Javascript jQuery registration form that appears in a pop-up window when a link is clicked. Here is the button I am working with: <a href="#" class="cta">REGISTER NOW</a> The goal is to have a simple HTML registra ...

Erase a set of characters with the press of the backspace key (JavaScript)

Within my textarea, I have lines that start with a number and a period: <textarea autoFocus id="text-area"wrap="hard" defaultValue ={this.state.textAreaVal} onKeyUp={this._editTextArea}/> For example: Line 1 Line 2 Line 3 I've created a ...

Manipulate Elements with jQuery: Adding a Class to a Child Element

HTML: <div class="cell-container"> <img src="image.png" class="thumbnail" /> </div> CSS: .hover { background-color: silver; } .hover-image { border: 1px solid #000; } jQuery: $(".cell-container").mouseover(function() { $(th ...

I require the integration of HTML elements within a Java class

import java.sql.*; import java.util.Properties; public class View { public static void main(String[] args) throws ClassNotFoundException, SQLException { Statement stmt = null; Connection connect =SPACE_DBController.SPACE_getConnection( ...

How to Update Font in Android Studio WebView

I am facing an issue with HTML: I am trying to implement a custom font in a webview but the font does not change when using this code: public void loadHTLMContentText(String text, WebView view) { String body; String head = "<head><style ...

I have been having trouble getting the entire background to display in a specific color with Styled Components

It seems like a simple issue, but I just can't get the background to cover the entire screen. Even though I have provided the code I used, only a quarter of the top of the screen appears black when wrapping something in the component. Here is the cod ...

live preview of row data in a thumbnail

I'm curious about creating dynamic thumbnails of logos from table rows, similar to the image below: https://i.sstatic.net/FooEz.png Here is the code I've been using: .numberCircle { border-radius: 50%; width: 30px; height: 30px; padd ...

Non-responsive image in Bootstrap 4

My struggle is with making my website fully responsive. Whenever I use the img tag with a width of 100% on a large screen, the image fits perfectly, but when the window is resized, a horizontal scroll appears, creating white spaces and causing the image ...

css media queries not taking precedence over default styles

Struggling to find a solution as no similar case was discovered!! To avoid adding a class name for each page, I am eager to utilize a generic class name as shown below: <div id="news"> <div class="news column">content 1</div> &l ...

Footnote fiascos

I am currently in the process of creating a footer for my webpage and have implemented the following CSS styling: #footer { height: 100px; background-color: #F3F3F3; position: absolute; bottom: 0; } Although the footer is displaying at th ...

I'm facing an issue with my LAMP stack where the image appears when I access it through a URL, but doesn't seem to load when I try to load it using jQuery

My PHP file is located at path/renderer/renderImage.php and it generates a PNG image that displays correctly in the browser when I visit the URL directly. However, when I try to load this image into a DIV using jQuery from path/index.html with the followin ...

Unable to relocate the cursor to an empty paragraph tag

Wow, I can't believe how challenging this issue is. My current project involves implementing the functionality for an enter key in a content editable div. Whenever the user hits enter, I either create a new p tag and add it to the document or split t ...

How can I utilize JQuery to dynamically refresh a dropdown menu?

My dropdown list is initially empty: <div> <label>Boarding Point </label> <select title="Select pickup city" id="boardingDropdown"> </select> </div> I am trying to popula ...

What strategies can be used to scale up a website's images in proportion to their page views or traffic?

The situation: On my simple HTML website, I have a group of images placed side by side. Each image is connected to a specific article, and when you hover over the image, a detailed description of the linked article pops up in the center of the page. The o ...

PHP Wordpress Plugin with Bootstrap Integration

I'm currently working on my first WordPress plugin to display some dashboard data on the wp-admin page. However, I am facing a challenge where only my PHP code is being recognized within the plugin, and any HTML markup that I include seems to be ignor ...

The webpage transforms with the holiday spirit

I have created multiple backgrounds for my website (available here), and I am looking for a way to have them automatically change based on specific occasions like Christmas, Halloween, etc. Manually changing them is an option, but where's the fun in t ...

Set the height of a div based on the height of another div

My challenge involves a textarea that dynamically expands as content is added to it. The structure of the textarea within a div element is illustrated below: <div id='sendMes' class='container-fluid'> <form action='#&apos ...

Implementing nth-child selector in vanilla JavaScript

Is there a way to dynamically change the number within the nth-child brackets when clicking on a button? For instance, can I click a button and have the next slide in a slideshow appear? .slideshow:nth-child(n){} I specifically need to modify n using only ...