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

What is causing lxml to not remove section tags?

Having some trouble parsing HTML using lxml and Python. My goal is to eliminate section tags, but seems like lxml can remove other specified tags except for sections. For instance: test_html = '<section> <header> Test header </header& ...

What could be the reason behind the button's lack of color change with this particular code?

I'm a beginner in web development and currently practicing HTML, CSS, and Javascript. I've added a button to my html file and would like the color of the button to change when it's clicked on. Here is my HTML code: <button id="box&q ...

Connect to a point on the leaflet map using an external <a> tag reference

I have a leaflet map and I am trying to create a link that, when clicked, will activate a specific marker on the map. Essentially, I want the linked marker to simulate being clicked when the link is clicked. Here is an example of the link: <a href="#" ...

How to Align Navigation Bar Items to the Right in Bootstrap 4

I need some help with bootstrap. I've looked at various discussions on this topic and tried numerous solutions, but I still can't get it right. I want the logo to be on the left and the navigation links aligned to the right. Here's what I&ap ...

I am experiencing slow load times for my Angular 2 app when first-time users access it, and I am seeking assistance in optimizing its speed

Below, you'll find a snippet from my app.ts file. I'm currently working with angular2, firebase, and typescript. I'm curious if the sluggish performance is due to the abundance of routes and injected files? The application functions smoot ...

Show a 1920x1170 / 183KB image as the background using CSS styling

I need help with displaying a background image that is 1920x1170 pixels and has a file size of 183KB. Here is the code I am using: .bground{ height:auto; left:0; position:fixed; top:0; width:100%; } <div class="bgrou ...

What is the best way to style these CSS elements within the stylesheet?

I'm currently working on customizing a navigation menu in DotNetNuke. Although my question primarily relates to CSS syntax. Can someone please provide guidance on how to style a class that resembles the following? <tr class="mi mi0-0 id58 first"& ...

Navigate through FAQ items with sliders using Owl Carousel 2 - Easily switch between different chapters

Exploring the creation of a FAQ section with individual carousels for each item. My primary objective is for the carousel to transition to the next chapter when advancing beyond the last slide (backwards navigation would be a future enhancement). I'v ...

Explanation for aligning anchors within an HTML <div>

I'm faced with this HTML snippet: <div class="row"> <div class="col-md-10 social-icons"> <a href="https://www.youtube.com/" target="_blank"><img src="/images/youtube-i.png"></a> <a href="https://gi ...

Problem with displaying Django input fieldsSolution for missing Django input

Currently, I am in the process of constructing a website using Django. One of my tasks involves transferring input from index.html to about.html through view.py. However, despite successfully passing the input as seen in the URL in the browser's addre ...

Error message: "Angular.js encountered a typeError stating that V2.example is not a function"

Having recently started learning Angular.js, I came across a tutorial that was created about a year ago. In this tutorial, I am attempting to implement a search feature that takes user input and searches for it on Github.com. Below is the HTML code snippet ...

The .remove() method is ineffective when used within an Ajax success function

I am facing an issue with removing HTML divs generated using jinja2 as shown below: {% for student in students %} <div class="item" id="{{ student.id }}_div"> <div class="right floated content"> <div class="negative ui button compa ...

Creating a clickable map for a PNG image: Step-by-step tutorial

My goal is to create a interactive map similar to this one. Click here for the image ...

Utilize Byte serving functionality in a Spring Boot application

I am facing an issue while trying to implement a video player in Angular using Spring Boot Rest API. The problem is that I can play the video but I am unable to seek through it. Whenever I try to shift the position of the video, it starts playing from the ...

Using Rails to load an image from CSS

My current approach to loading an image is using this code: <div id="bglion"><%= image_tag("BG-LION6.png")%></div>, which successfully displays the image. However, I am interested in loading the image from a CSS file instead. After resea ...

"Utilizing Bootstrap Tour for Easy Navigation: Automatically Scroll Back to the Top with

I have a Bootstrap tour set up with code that is meant to capture the user pressing the end tour button and scroll them back to the top of the screen. However, currently the code runs when a new popover loads instead of when the end tour button is clicke ...

What are some techniques for concealing a CSS transition beneath another element in both directions?

Witness the magic in action! By clicking on the black box below, a larger black box will gracefully emerge from beneath the sidebar. While it may not be as clear in jsfiddle, rest assured that this effect is more pronounced in browsers. Thanks to some clev ...

How can I ensure that my style.scss file effectively interacts with my stylesheet by including imports for "variables", "globals", and "header"?

Currently, I am in the process of learning how to utilize Sass and JavaScript through VS Code. Within my project structure, I have an "app" folder where my js folder resides containing script.js, as well as a scss folder holding _globals.scss, _header.scss ...

Accessing variables in Angular 2 using an event object

Struggling with accessing variables through an event object. Is there a way to refactor this code? I need to display annotations in my templateUrl after setting them in an event click of the map. Here's the current code snippet: import { Component, O ...

The custom font fails to load on a customized Material UI theme

In my React web application, I tried to implement a custom font by writing the following code: import React, { FunctionComponent } from 'react' import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles' import SofiaPro ...