When scrolling, the section content begins to cover up the header

I am currently working on a web page and encountering an issue with my fixed navigation bar. I have two sections on the page, and while scrolling, the first section behaves correctly, but the second section is overlapping the navigation bar. To better illustrate this problem, please refer to the JSFiddle link provided below.

My attempts to resolve this issue included setting the display property of .items to block, but that did not provide a solution. I also experimented with using position:absolute, but it negatively impacted the overall view of the page. As of now, everything on the page works fine except for the overlap issue where the second section (testimonial-one) is covering the header while the first section functions properly.

I also tried incorporating the nav-fixed-top class in my Bootstrap navigation, but unfortunately, that did not produce the desired outcome.

.navbar { padding: 26px !important; position: fixed!important; width: 100%}
.navbar a img {width: auto; height: 45px}
body{ padding-top: 0px; margin: 0; padding: 0; }

.home-page {background-image: url("assets/images/home_image.jpg"); background-size: cover; padding-bottom: 125px; padding-top: 0; background-repeat: no-repeat;}
.home-page H1 {font-family: "HelveticaNeueThin"; padding-top: 219px; font-size: 52px!important; color: #616161}

.testimonial-one {padding: 0}
.testimonial-one .content-offset {
  position: relative;
  min-height: 400px;
}

.testimonial-one {padding: 0}
<!doctype html>
<html lang="en<
  <head>
    <link rel="stylesheet" href="style.css">

    <!-- jQuery Script -->
    <script src="https://code.jquery.com/jquery-1.12.0.js"></script>

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
 </head>

  <body>
    <!-- Just an image -->
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
      <div class="container">
        <a class="navbar-brand" href="#home" style="border-bottom: none">
          <img src="img" alt="TESTING">
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="col-lg-2"></div>
        <div class="pt-lg-0 pt-3 collapse navbar-collapse" id="navbarNavAltMarkup">
          <div class="navbar-nav">
            <a class="nav-item nav-link" href="#page-1">HELLO</a>
            <a class="nav-item nav-link" href="#">WORLD</a>
            <a class="nav-item nav-link" href="#">HOW</a>
            <a class="nav-item nav-link" href="#">ARE</a>
            <a class="nav-item nav-link" href="#">YOU</a>
            <a class="nav-item nav-link" href="#">FINE</a>
          </div>
        </div>
      </div>
    </nav>

    <section class="home-page" id="home">
      <div class="container">
        <h1>Bringing ease to<br>each home</h1>
        <div class="d-none d-sm-block" style="margin-top: 400px"></div>
      </div>
    </section>

    <section class="testimonial-one container" id="page-1">
      <div class="content-offset">
        <img src="assets/images/left.png" alt='' class="prev"/>
        <img src="assets/images/right.png" alt='' class="next"/>
        <div class="container">
          <div class="items">
          <div><p style="font-size:80px">Hello</p></div>
            <div><p style="font-size:80px">Hello</p></div>
          </div>
        </div>
      </div>
    </section>
  </body>
</html>

If you could take a look at my JSFiddle link and provide some assistance, I would greatly appreciate it. Thank you. Link : JSFiddle Work

Answer №1

To resolve this issue, consider applying a z-index to your navigation bar. This will ensure that the navigation bar appears above other content on the page.

.navbar { padding: 26px !important; position: fixed!important; width: 100%; z-index: 10;}
.navbar a img {width: auto; height: 45px}
body{ padding-top: 0px; margin: 0; padding: 0; }

.home-page {background-image: url("assets/images/home_image.jpg"); background-size: cover; padding-bottom: 125px; padding-top: 0; background-repeat: no-repeat;}
.home-page H1 {font-family: "HelveticaNeueThin"; padding-top: 219px; font-size: 52px!important; color: #616161}

.testimonial-one {padding: 0}
.testimonial-one .content-offset {
  position: relative;
  min-height: 400px;
}

.testimonial-one {padding: 0}
<!doctype html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="style.css">

    <!-- jQuery Script -->
    <script src="https://code.jquery.com/jquery-1.12.0.js"></script>

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
 </head>

  <body>
    <!-- Just an image -->
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
      <div class="container">
        <a class="navbar-brand" href="#home" style="border-bottom: none">
          <img src="img" alt="TESTING">
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="col-lg-2"></div>
        <div class="pt-lg-0 pt-3 collapse navbar-collapse" id="navbarNavAltMarkup">
          <div class="navbar-nav">
            <a class="nav-item nav-link" href="#page-1">HELLO</a>
            <a class="nav-item nav-link" href="#">WORLD</a>
            <a class="nav-item nav-link" href="#">HOW</a>
            <a class="nav-item nav-link" href="#">ARE</a>
            <a class="nav-item nav-link" href="#">YOU</a>
            <a class="nav-item nav-link" href="#">FINE</a>
          </div>
        </div>
      </div>
    </nav>

    <section class="home-page" id="home">
      <div class="container">
        <h1>Bringing ease to<br>each home</h1>
        <div class="d-none d-sm-block" style="margin-top: 400px"></div>
      </div>
    </section>

    <section class="testimonial-one container" id="page-1">
      <div class="content-offset">
        <img src="assets/images/left.png" alt='' class="prev"/>
        <img src="assets/images/right.png" alt='' class="next"/>
        <div class="container">
          <div class="items">
          <div><p style="font-size:80px">Hello</p></div>
            <div><p style="font-size:80px">Hello</p></div>
          </div>
        </div>
      </div>
    </section>
  </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

"Utilizing Bootstrap 4: Understanding the Optimal Times to Implement the 'Row

After studying the fundamental guidelines for Bootstrap 4, a question has arisen in my mind: Under what circumstances should we utilize the .row class in our layout? I came across this example where the .row class was not used in the code. However, the ba ...

The hyperlink associated with the image is not functioning

We are currently in the process of building a website, but we seem to be encountering some issues with the links. Specifically, when navigating away from the homepage and clicking on the logo in the corner, we should ideally be directed back to the index ...

Efficiently determine optimal menu item dimensions using CSS automatically

Is it possible to automatically position menu items using CSS so that the position is recalculated when the menu item text changes? Currently, I have a menu created with ul li's and I am using padding for positioning. However, if the text becomes long ...

What Causes mat-bottom-sheet-container to Overflow Instead of Remaining Anchored at the Bottom of the Mobile Screen?

I am encountering an issue with a popup window in my Angular app. Despite testing it on various screen resolutions using Chrome's DevTools Screencast, the popup appears correctly styled and positioned on mobile devices. However, when tested on a real ...

Uploading Multiple Files with Base64 Encoding in PHP

I am looking for a way to store images in a database and retrieve them using base64 encoding/decoding. Can anyone guide me on how to achieve this? Here is the HTML code: <form method="POST" action="add_script.php" enctype="multipart/form-data"> ...

Versatile Function for Handling Dropdown Changes

I am faced with the challenge of executing a javascript function when multiple select elements are changed. I want to create a versatile function that can be set as the onchange method for various select elements. The following code accomplishes this task ...

Display the information contained within an array in a table using React

I have two arrays: one named formData and the other state array. const [formData, setFormData] = useState([]); let ure = [{}] useEffect(() => { axios .get("/api/listUre") .then((res) => { console.log(res.data ...

The website is displaying a strange mix of text and HTML when viewed on a PC

While browsing the internet for C programs, I stumbled upon this particular program that caught my eye: <span style='color:#004a43'>#</span><span style='color:#004a43'>include</span><span style='color:#8 ...

Stop modal from closing in the presence of an error

My approach involves using a generic method where, upon adding a food item, a modal window with a form opens for the user to input their details. However, since backend validation for duplicate items can only be retrieved after the API call completes. I w ...

Why is Google Chrome cutting off parts of my website?

Has anyone encountered the strange rendering issue in Google Chrome? Check out this bug here http://community.mediabrowser.tv/uploads/site_1/126/annoying_rendering_bug.jpg I sometimes experience it when I visit What is causing this issue? Is there a way ...

`Execute onClick function for submit button only when all the required input fields have been populated`

I have created a form with mandatory fields and included an onClick event listener on the submit button to show a loading spinner while the process is running. However, I am facing an issue where the onClick function is triggered every time the button is c ...

The CSS isn't loading properly once the file is uploaded to the server using FileZilla or cPanel

After uploading the file.css file to the server using both FileZilla and cPanel, I noticed that when I visit the website, the CSS is not being applied properly. Specifically, I changed padding-left: 10px; However, upon viewing the Page source, it appears ...

Set a consistent pixel measurement for all images

I am working on a project where I have an image of a card that needs to be repeated 30 times. Each time the card is repeated, I want it to overlap with the previous card in a specific position, resembling a deck of cards. The issue I am facing is that whe ...

How can I add seconds to the jquery datetimepicker plugin?

Looking to implement the datetimepicker plugin from here, but I'm having trouble finding information on how to include the seconds part. Is there a way to add seconds to this plugin? It's a crucial requirement, so any suggestions for another good ...

Tips for retrieving the hyperlink within an HTML anchor tag using JavaScript

Here's some HTML with JavaScript: document.addEventListener('mousedown', function(event) { let elem = event.target; let jsonObject = { Key: 'mousedown', Value: event.button }; if (event.button == 2) { console ...

Assistance with changing styles

Hey there, I could really use some assistance. I've created a style switcher, but I'm struggling to figure out how to replace the stylesheet properly. Currently, my code empties the <head> element when what I really need is for it to simply ...

Bootstrap: the rows are breaching the boundaries of their parent containers, causing them to overlap with

I'm struggling to create a bootstrap layout similar to the one on Codepen. Everything looks good on the codepen demo: Codepen_bootstrap ...but when I try to view the page locally in my browser (Chrome and Safari), the design becomes distorted and el ...

Simple filling out of a dropdown menu form

Currently attempting to populate a drop-down select menu from a table named "Cars" using the information in the "VIN" column. However, for some reason I am not seeing any data displayed. <form> <label>VIN:</label> <select name ...

An unconventional way to display an image using the :before pseudo-element and a data attribute in CSS

My goal is to use the :before pseudo-element to set an image background, as I plan to overlay content on top of it. In the past, I have dynamically set a data attribute with :before for other purposes. Question: Is there a way to change the number using ...

Close CSS Accordion when Clicked

I have a CSS accordion that I would like to close each panel upon clicking. Can this be accomplished using only CSS, or will JavaScript need to be added? #accordion input:not(:checked) + div { display: none; } #accordion input:checked + div { displ ...