CSS: Navigation menu causing a delay in the display of a div

Hey there, I am a beginner in HTML & CSS and currently working on my first website. I'm facing an issue with my navigation bar causing a delay in the div below it when set to relative position. When I switch it to absolute positioning, the centering of the div is perfect but the nav bar disappears. Any help would be greatly appreciated!

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>RATA</title>
    <link rel="stylesheet" href="css/styles.css">
    <link rel="icon" href="favicon.ico">
  </head>
  <body>
    <header>
      <img class="Logo" src="images/R-white.png" alt="Skull-Logo">
      <nav>
        <ul class="nav__links">
          <li><a href="#">Roadmap</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Team</a></li>
          <li><a href="#">FAQ</a></li>
        </ul>
      </nav>
      <a class="cta" href="#"><button>Mint</button></a>
    </header>
    <div class="Start">
    <img class="background" src="images/RATA-small.svg" alt="RATA">
    </div>
  </body>
</html>

CSS

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap');

/************** PARAM SELECTORS ******************/

body {
  margin: 0;
}


/*******************CLASS SELECTORS*****************/

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  background-color: #191919;
  z-index: 1;
}

li, a, button {
  font-family: 'Montserrat', sans-serif;
  font-weight: 500;
  font-size: 16px;
  color: #edf0f1;
  text-decoration: none;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30px 10%;
}

.Logo {
  cursor: pointer;
  height: 100px;
  margin: 0;
}

.nav__links {
  list-style: none;
}

.nav__links li {
  display: inline-block;
  padding: 0px 20px;
}

.nav__links li a {
  transition: all 0.3s ease 0s;
}

.nav__links li a:hover {
  color: #0088a9;
}


.cta button {
  padding: 9px 25px;
  background-color: rgba(0, 136, 169, 1);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease 0s;
}

.cta button:hover {
  background-color: rgba(0, 136, 169, 0.8)
}

/**Div**/
.Start {
  position: relative;
  bottom: 0;
  width: 100%;
}

/** Image in Div**/
.background {
  margin-top: 0px;
  bottom: 0;
  position: relative;
  z-index: 0
}

Answer №1

The image in the div appears too large for my screen, requiring me to scroll.

This issue may be resolved by setting the image height to 200px:

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap');

/************** PARAM SELECTORS ******************/

body {
  margin: 0;
}


/*******************CLASS SELECTORS*****************/

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  background-color: #191919;
  z-index: 1;
}

li, a, button {
  font-family: 'Montserrat', sans-serif;
  font-weight: 500;
  font-size: 16px;
  color: #edf0f1;
  text-decoration: none;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30px 10%;
}

.Logo {
  cursor: pointer;
  height: 100px;
  margin: 0;
}

.nav__links {
  list-style: none;
}

.nav__links li {
  display: inline-block;
  padding: 0px 20px;
}

.nav__links li a {
  transition: all 0.3s ease 0s;
}

.nav__links li a:hover {
  color: #0088a9;
}


.cta button {
  padding: 9px 25px;
  background-color: rgba(0, 136, 169, 1);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease 0s;
}

.cta button:hover {
  background-color: rgba(0, 136, 169, 0.8)
}

/**Div**/
.Start {
  position: relative;
  bottom: 0;
  width: 100%;

}

/** Image in Div**/
.background {
  margin-top: 0px;
  bottom: 0;
  z-index: 0;
  width: 100%;
  height: 200px;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>RATA</title>
    <link rel="stylesheet" href="css/styles.css">
    <link rel="icon" href="favicon.ico">
  </head>
  <body>
    <header>
      <img class="Logo" src="images/R-white.png" alt="Skull-Logo">
      <nav>
        <ul class="nav__links">
          <li><a href="#">Roadmap</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Team</a></li>
          <li><a href="#">FAQ</a></li>
        </ul>
      </nav>
      <a class="cta" href="#"><button>Mint</button></a>
    </header>
    <div class="Start">
    <img class="background" src="https://images.unsplash.com/photo-1648852071390-7a17e3f2580a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80">
    </div>
  </body>
</html>

To view the snippet fullscreen on your device, click the Full Page button

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

Incorporate the "0" character into a PHP JSON call

I am currently working on a PHP page to retrieve data from Forecast.io's API. When looking at the daily view, they represent the days as numbers. I specifically need information for today, which is represented by the number "0." Here is an excerpt of ...

Issue with offset calculation in bootstrap table occurs when the bootstrap-table is closed and the window is resized

In a recent project, I utilized the bootstrap table. However, upon closing the bootstrap table with the following script: $(document).ready(function () { $(".removetable").click(function (e) { $(".table-aria").remove(); ...

Retrieving the CSS property values for a specific element using Selenium

Imagine a scenario where I locate an element by its XPath using: WebElement element = driver.findElement(By.xpath("specific XPath")); While I can retrieve the value of a single CSS property with element.getCssValue("specific property"), is there a way to ...

Tips on effectively managing sibling nodes with unique behavior on the initial one

Greetings and thank you for taking the time to read and assist. While I have gained a good understanding of how XSLT 1.0 processes XML, there is one issue that continues to baffle me. The problem arises from having a template that matches the first node ...

Where is my image hiding on my website?

I've been struggling with this issue for a while now. Whenever I try to run my website, the images simply won't upload. Even though I can clearly see the file on the page. click here to view image ...

Troubleshooting: Jquery UI Draggable - Cursor losing track of draggable element

I want to create a draggable popup with Jquery UI functionality, but I'm facing an issue where the cursor does not stay aligned with the popup element when dragged. When dragging the popup element to the left, the mouse cursor goes beyond the div elem ...

Utilizing the '::marker' pseudo-element for generating Markdown-inspired headers

This code snippet is functioning correctly, however, I have a suggestion to make it more appropriate. Instead of using '::before', why not try using '::marker'? I attempted this adjustment but encountered an issue. Can anyone explain wh ...

Retrieve the outcome from the PHP webpage

I have recently developed a contact page, but I am experiencing an issue with the submit button's functionality. When I click on the submit button, the form is supposed to send the information to a PHP file on the server-side. However, the button does ...

Tips for setting up an automated system to check feeds

While I have experience parsing and setting up databases in PHP, I am now faced with the challenge of constantly monitoring an XML feed for a specific string within one of the tags. Each time this string is detected, I need to add the entire XML item (incl ...

Creating a design with multiple `<thead>` and `<tbody>` elements

Seeking advice on usability and design elements. I am currently utilizing JQuery to hide/show entire sections within a single large table structure. The layout consists of multiple thead sections, with the main header at the top, followed by sub-headers fo ...

I'm having an issue with Internet Explorer where the link doesn't function properly when I enclose the content within an <a> tag. Could anyone

I understand that this might not be the preferred approach, but a customer has requested live text wrapped in just one HTML tag.... Here's the challenge I'm facing: I currently have some code structured like this: <a href="google.com"> ...

Change the background color of a table cell based on its value with the help of JavaScript

I am attempting to apply color to cells in an HTML table (generated automatically by Python and Django) based on the content of the cells. Below is my table. I want to specifically color the column "status". Whenever the word "Cloture" appears, I would li ...

Tips for saving values created with JavaScript as an HTML file

I am looking to download an appended value as a HTML file. In my code, values are being appended from an external HTML file through an iframe. The code is functioning correctly and retrieving the right value. Now, I just need to download that appended valu ...

Take away the focus from Bootstrap 5 toggle button once it has been clicked

Working with the Bootstrap 5 Toggle Button in Outline Style to enhance visual emphasis hasn't provided the ideal user experience I was hoping for. (Refer to https://getbootstrap.com/docs/5.0/forms/checks-radios/#outlined-styles) The toggle functional ...

Encountered an issue while attempting to retrieve the access token from Azure using JavaScript, as the response data could

Seeking an Access token for my registered application on Azure, I decided to write some code to interact with the REST API. Here is the code snippet: <html> <head> <title>Test</title> <script src="https://ajax.google ...

Place the footer element at the bottom of the page in relation to its preceding sibling

Having an element positioned at the bottom of a page can sometimes be tricky, especially when there are elements that slide up and down based on user interactions. On pages with enough content to push the element down naturally, everything works fine. The ...

Utilizing CSS classes to namespace pseudo-selectors

After attempting to search on Google, I am struggling to find the right keywords. I'm trying to apply a pseudo-selector only to a specific class. In this scenario, if we remove the specified class, the last Hi should appear in blue. However, my expe ...

Efficiently managing memory and caching content in jQuery Mobile

This situation is really starting to get to me. In the project I am working on using jqm, there is a specific page with collapsible blocks containing listviews that populate dynamically when expanded. Each listview contains around 500 elements, each with ...

Troubleshooting the vertical alignment problem in Bootstrap 4 navigation bars

Below is the code I am using for my navbar: <nav class="navbar navbar-expand-lg navbar-light bg-light"> <a class="navbar-brand" href="/">BRAND</a> <div class="navbar-collapse"> ...

Reset the queue for the slideDown animation using jQuery

I am experiencing an issue with my code where multiple animation effects are running simultaneously. Specifically, when I hover over navbarli1 and then move to another li element with the same navbarli1 class, the slide-down effect is not working as expect ...