Sticky Angular header that keeps content visible while scrolling - no disappearing into the header

I came across a discussion about sticky headers and implemented the following Angular layout:

<div fxLayout="column">
    <div class="sticky">
        <app-header></app-header>
        <app-navbar></app-navbar>
    </div>
 
    <div fxLayout="row" fxFlex="100">
        <div class="my-content">
            <router-outlet></router-outlet>
        </div>
   
    </div>
</div>

After applying the sticky CSS to make the header and navbar stay at the top while scrolling, everything seems to be functioning correctly. However, as I scroll and the main content moves up, it does not disappear beneath the header section. The labels, textboxes, and grid elements remain visible.

I tried adding styles to "my-content" div with overflow set, but the issue persists:

.my-content {
    padding: 0 15px;
    width: 100%;
    overflow: hidden !important;
}

I've reviewed the post multiple times but still can't figure out how to make the content hide under the banner. Any assistance would be greatly appreciated. Thank you!

https://stackblitz.com/edit/angular-9-0-0-rc-1-ccgxry?file=src%2Fstyles.scss

Answer №1

After much contemplation, I finally unraveled the solution and incorporated a z-index property.

.header-sticky {
    width: 100%;
    position: fixed;
    top: 0;  
    z-index: 10;
    background:inherit;
}

.my-content {
    padding: 0 15px;
    width: 100%;
z-index:5;
    overflow: hidden !important;
}
 

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

Unable to create a horizontal navigation bar

After spending a considerable amount of time on this task, I am perplexed as to why the navbar is not aligning horizontally. I have tried various techniques such as floating to the left and using display inline, but nothing seems to be working. Could there ...

"Modify the CSS color of h1 based on the presence of a specific class containing spaces in a div

I am currently attempting to modify the color of a heading by referencing a specific div's class. My attempts so far include: .pagetitle-title.heading { color: purple; } <div class="container"> <h1 class="pagetitle-title heading">I ...

Expansion Issue: Div in Main Section Not Adapting to Parent Width in Bootstrap Flex Layout

I have a Bootstrap 5.2 header/main/footer layout where I want the main section to expand and fill the page between the header and footer completely. The code below is currently working: <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a ...

Transform CSS into React.js styling techniques

My current setup involves using Elementor as a REST Api, which is providing me with a collection of strings in React that are formatted like this: selector a { width: 189px; line-height: 29px; } Is there a tool or library available that can conver ...

Learn the process of covering the entire screen with a video

I'm attempting to achieve this: IMG Below is the code snippet I've been using: <div class="container" id="containervideo"> <div id="video"> <div class="box iframe-box"> <div class="container"> ...

Is the CSS3 bar chart flipped?

I'm currently developing a responsive bar chart, and everything seems to be going smoothly except for one issue - when viewing it in full screen, the bars appear to be flipped upside down. It's quite puzzling as all other elements such as text an ...

Getting Specific Error Types in Angular 2 Form

My goal is to display the appropriate error message when a field is empty, too short, or too long. Here is a snippet of the form I am working with: <form #applicationForm="ngForm" (ngSubmit)="saveApplication()" class="form-horizontal"> <div ...

Why does Internet Explorer display .png images in lower quality compared to other browsers?

My menu displays a .png file with smooth edges in most browsers, but in Internet Explorer it appears with rough edges. Can someone help me understand why IE treats .png files differently compared to other browsers? <li> <a href="" onclick=" ...

Eliminate the empty gap preceding the slideshow

I have a slideshow and aside content in HTML. My goal is to eliminate the space below the slideshow so that the aside content can be positioned right next to the end of the slideshow. Unfortunately, I am unsure how to remove this space without disrupting ...

Troubleshooting issue with Express.json() functionality in the latest release of version 4.17

I'm currently exploring the MEAN stack and I am focused on performing CRUD operations. However, when I send data in the request body from Angular to the server, I end up receiving an empty request body. I'm unsure of where I might be making a mis ...

Is there a way to trigger a modal popup when hovering over a Bootstrap 5 card?

After coming across a handy template online, I decided to implement a modal pop-up feature when hovering over cards using Bootstrap 5. Here's what I have so far: class SavedEpisodes extends Component { $(function() { $('[data-toggle=&qu ...

Using Jquery variables for calculations and they do not work with numerical values

Hey there, I'm new to this so bear with me. I have a jQuery question that's puzzling me... I'm attempting to set the line height using the following method: var line_height = $('.container').css("height"); console.log(line_height ...

What is the reason behind the malfunctioning of this navigation menu?

This is a responsive navigation bar created using bootstrap. The issue I am facing is that I want the navigation items to be displayed in a single row. Here is the fixed-top navbar: Below is the navigation menu code: https://i.sstatic.net/Zqrvm.png ...

What is preventing me from running UNIT Tests in VSCode when I have both 2 windows and 2 different projects open simultaneously?

I have taken on a new project that involves working with existing unit tests. While I recently completed a course on Angular testing, I am still struggling to make the tests run smoothly. To aid in my task, I created a project filled with basic examples f ...

When transitioning between views in Angular App, it freezes due to the large data response from an HTTP request

I am encountering an issue with my Angular 9.1.11 application where it freezes after navigating from one page to another (which belongs to a different module with lazy loading). Here is the scenario: There is an action button called View Report that re ...

Angular: Is it possible to inject the Router into a component even if it hasn't been explicitly declared in the providers array?

Imagine we have this particular component: @Component({ selector: 'app-home', templateUrl: './home.component.html', styleUrls: ['./home.component.css'] }) export class HomeComponent implements OnInit { constructor(pri ...

Utilizing Angular 5: Enhancing ngFor with a Pipe and a Click Event

Iterating through an array of objects using *ngFor, I apply various filters via pipes to manipulate the resulting list. One of these pipes relies on a user input from a search field. Upon clicking on one of the ngFor elements, the corresponding object is p ...

Perform a check on the state of the slideToggle using an if-else function and provide a report on the slideToggle state

http://jsfiddle.net/vmKVS/ I need some help understanding the functionality of slideToggle using a small example. After toggling for the first time, the options element changes color to green. However, I expected the menu element to turn red when I togg ...

Creating flex items that mimic the fluidity of text

Is there a way to achieve fluid text behavior for flex items like in the following example: .container{ display: flex; flex-wrap: wrap; max-width: 200px; background: red; } div:not(.container){ w ...

What is the process of connecting an ngForm to a component?

I am working with an angular component called "form-fields" that dynamically creates form inputs based on an array of input types. My issue arises when trying to include this component within a larger form structure: <form #form="ngForm" autocomplete=" ...