Headerbar overlapping Div when scrolling

I'm currently trying to create a fixed header bar that allows the content of the page to scroll beneath it rather than displaying above it. This functionality is working on multiple pages, but I'm experiencing issues with my calendar page.

When scrolling, the content should behave as shown in this image: https://i.stack.imgur.com/lz6v4.png

On other pages, the content successfully goes under the header bar. However, on the calendar page, this behavior doesn't work. Below is the HTML and CSS code for the header bar:

<div class="headerclass">
  <nz-header class="header-bar">
    ...
  </nz-header>
  <!--dropdownMenu-->
  <div class="menu">
    ...
  </div>
</div>
/* Media queries for smaller screens */
@media screen and (min-width: 800px) {
  #menuButton {
    display: none;
  }
}

...
.headerclass {
  position: fixed;
  width: 100%;
  z-index: 1;
}

The use of z-index can be seen in the CSS snippet above. Am I implementing it correctly? The following code pertains to the calendar section:

<div class="calendar">
  ...
</div>
.calendar {
  margin-left: 2%;
  margin-right: 2%;
  padding-top: 75px;
  z-index: 2;
}

This particular section utilizes the ng-zorro library. If anyone has insights on how to resolve this issue, I would greatly appreciate it.

Answer №1

Your current issue is caused by the z-index of the calendar being set higher than that of the headerclass.

It's important to understand that the z-index property determines the stacking order of elements on a web page. A higher value means a higher positioning in the stack.

To correct this issue, adjust the styles as follows:

   nz-header,
nz-footer {
  background: #7dbcea;
  color: #fff;
  width: 100%;
  position: relative;
  z-index: 2;
  top: 0;
}

.headerclass {
  position: fixed;
  width: 100%;
  z-index: 2;
}
 .calendar {
  margin-left: 2%;
  margin-right: 2%;
  padding-top: 75px;
  z-index: 1;
  }

By making these changes, you should be able to resolve the problem. Good luck!

Answer №2

Looking to set the z-index property to determine the element's level? Give this a try:

#header {
  background-color:#990000;
  position:fixed;  
  z-index:1; /*Make sure to include this*/
  width:100%;
  height:50px;
  text-align:center;
  vertical-align:middle;
  line-height:50px;
  top:0px;
}

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

The last value label in Google Charts bar chart getting cut off

I've searched extensively for a solution to this issue regarding the haxis labels, but I have not been able to find one that addresses it... In the image provided below, you'll observe that the last percentage label on the horizontal axis is mis ...

Updating object properties in Typescript

I have written the following Angular 2 TypeScript code: import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) ...

Struggling to generate a div using my JS/jQuery code

Currently working on a post-it web application to improve my skills in JavaScript and jQuery. I've encountered a few errors that have me stumped. Although I'm new to StackOverflow, I often use it as a helpful resource. You can find the code here ...

A simple way to add a value from a select option into a textarea when there are several dropdown menus and select elements sharing the same

I have several divs with the same class names where I need to input a value from a dropdown menu into the textarea that belongs to the div where the select element is located. I want this function to work smoothly even with more than 10 divs, which is why ...

Grouping elements of an array of objects in JavaScript

I've been struggling to categorize elements with similar values in the array for quite some time, but I seem to be stuck Array: list = [ {id: "0", created_at: "foo1", value: "35"}, {id: "1", created_at: "foo1", value: "26"}, {id: "2", cr ...

Python Selenium - encountering issues with interactability of elements

Trying to complete the form on () is proving tricky for me. When I utilize Javascript, document.getElementsByName("userName")[0].value = "Hello", I am successful in entering text into a form. However, when I apply the same logic in Sel ...

Generating a fresh array based on the size of its existing elements is the key feature of the ForEach method

When running this forEach loop in the console, it extracts the property "monto_gasto" from an array of objects in the firebase database. Here's how it looks: something.subscribe(res => { this.ingresos = res; ...

Issue with anchor tag not functioning properly within toggle div

Can you please help me troubleshoot why the anchor tag is not functioning properly within my div elements? When I click on the first div, the second div is displayed but the anchor tag inside the first div does not seem to be working. <script> $(&ap ...

Transferring data between two HTML files through the POST method

Is there a way to pass two values (parameters) from one HTML page to another without displaying them in the URL, similar to using the POST method? How can I retrieve these values on the second HTML page using JavaScript, AJAX, or jQuery? For example: cli ...

Tips for creating a hover effect on a rounded outline button with a gradient border

What I am looking for: I want the buttons to have rounded corners; The buttons should use linear-gradient, with button A as the border and button B as the background color; When hovering over the buttons, the opacity should change to 0.5. This works fine ...

Parallel Execution Issue with RxJS Observable forkJoin

Struggling to understand why my requests aren't executing concurrently with the following code. As a newcomer to RxJS and observables, I would greatly appreciate any guidance on improving this snippet below. Essentially, I am fetching data from a REST ...

Utilize regular expressions to substitute content with HTML tags within a directive

While working with Angular JS to iterate through Twitter tweets using ng-repeat, I encountered the need to highlight certain parts of the tweet string such as @tag and #hash. To achieve this, it was suggested to utilize replace method to wrap these element ...

Choose the option in real-time with Jquery

I'm currently developing a dynamic HTML for Select Option as seen below: item += "<td class='ddl' style='width:40%;'>"; item += "<select>" item += " <option id='list' name='selector' value=" + se ...

Span tag not respecting CSS width property

One of my spans is causing an issue. Here are the styles in question: .form_container .col1che { float: left; width: 4%; text-align: left; } .form_container .col2che { float: left; width: 80%; text-align:left; } .form_container .col3che { float: ...

Inject the data within Observable<Object> into Observable<Array>

I'm faced with a situation where I have two distinct API endpoints. One endpoint returns a single Card object, while the other endpoint returns an Array of Card objects. My goal is to retrieve the first Card from the single Card endpoint and place it ...

Angular | The parameter type 'User[]' is incompatible with the expected parameter type 'Expected<User>' and cannot be assigned

While testing Angular, I encountered this error that has me stumped. The issue seems to be with the user inside the toBe() function. This error is occurring in the file user.service.spec.ts it('should call getUsersById', () => { const user ...

Searching for a specific element using a CSS selector

Looking for a way to find an element using a CSS selector in Chrome, I followed these steps: Right-click on the object Select "inspect" Right-click on the highlighted area in Chrome developer tools Choose "copy" Click on "copy selector" This is the cod ...

There seems to be no clear reason as to why the Angular Service is showing

In my DataService component, I have defined two methods - one to read from a file using the cordova-file-plugin and the other to write to it. Initially, it was using the in-mem-web-api, which worked perfectly fine. However, I made some changes to switch th ...

Angular 6 offers a dynamic auto complete feature that enhances user

My Angular app has auto-complete functionality enabled. I am using ngFor to iterate over an array of objects and passing the index of the object array to a function for some operations. Below is the code snippet I have tried: template.html <mat-form ...

Using Express to Deliver Static Content to Subdirectories

I am currently using Express to serve a React application that was bootstrapped with Create React App. The project has the following directory structure: |--client/ | |--build/ | | |--static/ | | | |--main.css | | | |--main.js | ...