How come my label and input are showing up in my navigation bar?

For my assignment, I am designing a website layout and facing an issue where the text appears behind the navigation bar instead of below it. I have tried adjusting the margin-bottom to 50px with important tags and setting the nav bar as static.

Despite trying various settings and configurations, including messing around with different options, I haven't found a solution that works effectively.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Website Title</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
    <link href="https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i&display=swap" rel="stylesheet">
  </head>
   <header>
        <nav>

            <ul>
                <li class="website-title"><a href="#">Website Title</a></li>
                <li><a href="Home">Home</a></li>
                <li><a href="About">About</a> </li>
            </ul>
         </nav>
    </header>

  <body>
    <div class="search-bar"> 
      <input type="text" placeholder="Search for Jobs"> </input>
      <label> Search Jobs </label> </div>


  </body>
</html>



head{
font-family: 'Roboto', sans-serif;
height:100vh;

}

nav{
  top:0;
  right:0;
  left:0;
  background-color:#dddddd;
  position:fixed;
  padding:10px;
}

ul {
  width:100vw;
    margin: 0;
    padding: 0;
}
​
li {
    list-style-type: none;
    float: right;
    text-align:center;

}

.website-title {
  float:left;
  text-align:center;
  font-size:25px;
}

li a {
    display:block;
    padding:8px;
    color:purple;
    font-size:20px;
    text-decoration:none;

    }

Answer №1

Since your navigation is set to position: fixed;, it does not affect the positioning of the rest of your content on the page. Elements that are absolutely positioned, such as absolute, sticky, or fixed, do not interact with the DOM in the same way as standard elements do. To address this issue, you can add a margin-top to your content like so:

header{
font-family: 'Montserrat', sans-serif;
height: 90%vh;

}

nav{
    top:0;
    right:0;
    left:0;
    background-color:#f1f1f1;
    position:fixed;
    padding:10px;
}

ul {
    width:100%vp;
    margin: 0;
    padding: 0;
}

li {
    list-style-type: none;
    float: right;
    text-align:center;

}

.gregs-title{
    float: left;
    text-align:center;
    font-size:25px;
}

li a {
    display:block;
    color:purple;
    font-size:20px;
    text-decoration:none;
    padding:8px;
}

body{
    margin-top: 60px;
}
<!DOCTYPE html>
<html>
  <header>
    <title>Custom Header</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
  </header>

  <body>
     <nav> 
        <ul>
            <li class="gregs-title">Greg's Site</li>
            <li><a href="About.asp">About</a><li><a href="Contact.asp">Contact</a>
         </ul>
    </nav>
  
    <div class="search-bar"> 
      <input type="text" placeholder="Search for items"> </input>
      <label> Search Items </label> 
   </div>


  </body>
</html>

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

Guide on making a custom page by substituting specific text with user-provided input based on an existing sample page

I'm looking to create a webpage with a form <form class="col s12" method="POST" action="addtask.php"> <div class="row"> <div class="input-field col s6"> <input placeholder="Username" id="user" type="text" class="v ...

How can I create my own unique scrolling behavior in JavaScript?

Looking to create a similar effect as seen on this website: where the vertical scrollbar determines the movement of the browser "viewport" along a set path. I believe that using Javascript to track the scroll bar value and adjust background elements acco ...

the script is run only one time

I have developed a unique web component and incorporated it in two distinct sections like this. <div class="sub_container"> <label>Users in Debt</label> <input placeholder="Search by user name" class="input_style ...

What steps should be taken to refresh a page following an AJAX file upload?

I need some help creating a progress bar to track file uploads on my website. Here's what I have so far: HTML: <form action="upload/files.php" method="post" enctype="multipart/form-data" id="frmUpload"> <input type="file" name="upfile" ...

Is there a way to conceal/remove the text displayed on the submit button?

I am facing an issue with a submit button in my PHP code. The button displays an integer value that is crucial for running a script, but I want to hide the value as it interferes with the design using CSS. I have attempted various solutions like removing t ...

Text-color in the v-tooltip

Is there a way to change the text color of v-tooltips components without affecting the tooltip background color? I attempted to inspect the element, but the tooltip only appears on hover, making it impossible to inspect. Below is the code snippet: < ...

What might be the reason for the border not reaching the bottom of the popup in my chrome extension?

I am currently working on a Chrome extension and using Bootstrap 5 with Sass to style its popup. However, I have encountered an issue where the border of the popup does not extend to the bottom as expected. What could be causing this problem? popup.html & ...

I am seeking guidance on extracting specific data from a JSON file and presenting it in an HTML table using jQuery

I am currently working on extracting specific elements from a JSON file and displaying them in an HTML table. I have successfully retrieved the data from the JSON file, stored it in an array, and then dynamically created an HTML table to display the conten ...

Concealing a DIV element when the value is not applicable

I'm currently working on a website for a coffee shop product. On this site, each product has a coffee strength indicator that is determined by the database. The strength can be categorized as Strong, Medium, Weak, or n/a (for non-coffee products). If ...

Tips for positioning an inline label and input field in an Angular application using CSS and HTML: How to align the label to the left and the input

I'm currently developing an Angular form with multiple label-input field combinations. I have managed to style the labels and input fields with inline block so that they appear on the same row. However, I am facing a challenge in aligning the label to ...

Tips for customizing the scrollbar design in iOS Safari

Task at hand requires me to customize the scrollbar style on my HTML page. Below is the CSS code I am using: .txt_Content::-webkit-scrollbar { width:5px; border-radius:4px; } .txt_Content::-webkit-scrollbar-button { display: none; } .txt_Co ...

Check to see if the menu item exceeds the allotted space, and if so, display the mobile menu

Currently, I am in the process of creating a unique responsive menu for my website that I think will need some JavaScript implementation. My skills with JavaScript are not very strong, so I am looking for guidance, code examples, or resources that can assi ...

Flashing on objects, Chrome-exclusive, utilizing background-blend-mode exclusively

Our website, www.desirio.com, utilizes a background-image on the body with the following CSS property: background-blend-mode: luminosity An issue we have noticed in Chrome is that when hovering over elements, strange white lines randomly flash on the scr ...

Tips on maintaining the original text hues that were established using setForeground() when a QTableWidgetItem is picked

Issue at Hand: Currently, when the first row is selected as shown in Figure 2 below, all text colors are changed to black, instead of maintaining their original style displayed in Figure 1. Is there a way to retain the original colors when a row is selec ...

Newbie in PHP: Techniques for transferring PHP variables between different sections of PHP code

In my project, I have a file named index.php which is responsible for uploading files to the server and setting PHP variables such as $target_folder_and_file_name. This index.php file also includes the following line (originally it was in an index.html fi ...

Ways to position a div at the center of a page

I've encountered a challenge while creating a mobile website. Within the main div, there are three nested divs. Initially, I aimed for left alignment but now desire to center-align these three divs on the page. Essentially, if the device screen is wid ...

Is it possible to execute a server-side click on a div element?

I have a div with an image and name inside. How can I make this div trigger a server-side click event without changing its structure? Here is my code: <div class="tutorial" style="margin-left:5px;"> TUTORIAL<div class="firstico" style=" ...

A guide to using Angular to emphasize text based on specific conditions met

Currently, I am developing a testing application that requires users to choose radio type values for each question. The goal is to compare the selected answers with the correct answers stored in a JSON file. To achieve this, I have implemented an if-else ...

Determine the selected option in the dropdown menu upon loading the page and when clicked

I am working on capturing the value of a drop-down list whenever it is changed or when the page loads. The aim is to display different div elements based on the selected option in the report field - either State or Year. Any assistance with this would be ...

A 2x2 Bootstrap grid that spans the full height of the viewport, where each cell has vertical overflow set to auto

I need help creating a grid with 100% height that has the following layout: The second row should expand to fill the remaining vertical space, even if cells C & D have limited content. Additionally, if the content in cell D is too large, I want a ver ...