CSS - Fixed header does not move when scrolling

Hey there! I'm working on an Angular application where I've set up sticky Filters and Header rows using HostListener and window scroll. However, I've encountered a small issue where the content of both the Header and filters overlaps with the results when users scroll down.

I could really use some assistance in resolving this overlap situation.

Check out my demo here: -

https://i.sstatic.net/26ICu.png

Here's a snippet of my FILTERS code:

html

<div class="filters-data"  [ngClass]="{'mat-elevation-z5' : true, 'sticky' : isSticky}">
    <div class="im-results">
        <div>
            <strong>{{ Amazon Data }} </strong> match
        </div>

    </div>

    <div class="filters-data-result">
        <app-filters-data-result *ngFor="let item of filters; let i = index" [item]="item" (onRemoved)="remove(item)">
        </app-filters-data-result>
    </div>
</div>

CSS section

    
.mat-elevation-z5 {
  position: relative;
}

.sticky {
  position: fixed;
  top: 100px;
}

div.filters-data {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-around;
    align-items: center;
    align-content: flex-start;
    padding: 20px 0;


    .im-results {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        align-content: center;
        font-size: 18px;
    }

    .filters-data-result {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
        align-content: center;
        margin-right: 8px;

    }

  }

.ts

  isSticky: boolean = false;

  @HostListener('window:scroll', ['$event'])
  checkScroll() {
    this.isSticky = window.pageYOffset >= 10;
  }

HEADER CODE

html


    <div class="header-top bottom-border mb-10" [ngClass]="{'mat-elevation-z5' : true, 'sticky' : isSticky }">
        <div class="am-ctnr rows-header">
            <div class="im-header-product">
                <div> Products</div>
            </div>
            <div class="im-number">
                <div> Number</div>
            </div>
            <div class="shippment-number">
                <div>Shipment Number</div>
            </div>
            <div class="origin">
                <div>
                    Origin
                </div>
            </div>
            <div class="size">
                <div>
                     Size
                </div>
            </div>
        </div>

    </div>

CSS

.header-top{

    .im-error-notification-div{
        overflow:hidden;
        .im-error-notification-inner{
            float:right;
        }
    }

    &.bottom-border {
        border-bottom: 1px solid am-colors.$ash-grey;
    }

    .mb-10 {
        margin-bottom: 10px;
    }

    .am-ctnr {
        display: flex;
        padding: 5px 16px 10px;
        align-items: baseline;
        flex-wrap: wrap;

        @media #{am-responsive-breakpoints.$screen-xs-sm-md}{
            display: none;
        }

        &.rows-header {
            font-family: am-fonts.$am-font-family-bold;
            font-size: 11px;
            font-weight: bold;
            justify-content: space-between;

            .im-header-product{
                padding: 5px;
                width: 30%;
            }

            .im-header-catalog{
                padding: 5px;
                width: 10%;
            }
            .im-header-lot-number{
                padding: 5px;
                width: 10%;
            }
            .im-header-origin{
                padding: 5px;
                width: 10%;
            }
            .im-header-unit-size{
                padding: 5px;
                width: 5%;
                min-width: 60px;

            }
            .im-header-item-price{
                padding: 5px;
                width: 10%;
            }
        }

    }
}

Answer №1

To position the header over the content, consider utilizing z-index and setting a background color.

Here's an example:

z-index: 99;
background-color: #fff;

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

Install global npm modules in alternative directories for Node.js

Currently, I am encountering difficulties with installing global modules on my Ubuntu Unix OS. Upon investigating the location of the node_modules folder, I discovered that npm had installed some global modules in /usr/lib/node_modules while others were ...

Using Modal Functions in AngularJS Controller

I have been working on a project that utilizes the ui.bootstrap. As per the instructions from the tutorial I followed, my setup looks something like this: 'use strict'; angular.module('academiaUnitateApp') .controller('EntryCtr ...

A guide on selecting the best UI container based on API data in React using TypeScript

I have been developing a control panel that showcases various videos and posts sourced from an API. One div displays video posts with thumbnails and text, while another shows text-based posts. Below is the code for both: <div className=""> &l ...

"Enhance your website's user experience with the ability to zoom in and out

One issue I encountered on my website was that when I included an iframe, the map would zoom in and out while scrolling. To try to fix this, I set pointer-events to none. However, this caused all actions on the map to be disabled, making it impossible to n ...

Retrieve data attributes to obtain details about the slider before and after

My task is to create a slider with information about the previous and next slides. For example, in the slider, there are left < and right > arrows. Behind these arrows, there are circles. When you hover over any arrow to change the next or previous ...

The absence of the 'Access-Control-Allow-Origin' header on the requested resource has been detected in AngularJS

Currently, I am working on an application that utilizes a PHP CodeIgniter RESTful API as the server side and the Ionic framework for the client side app. I have been facing an issue while trying to establish a connection between the client app and the serv ...

Strategies for iterating over an array in React with TypeScript

I'm currently working on looping through an array to display its values. Here's the code I have: ineligiblePointsTableRows() { return this.state[PointsTableType.INELIGIBLE].contracts.map(contract => { return { applied: (&l ...

unable to retrieve correct value upon click

Within my setup, there exists a slider with accompanying left and right buttons. Two event handlers are present for each button as demonstrated in the code below. Upon clicking and allowing the transition to complete its process, everything functions corr ...

The placeholder text in the input field is not functioning/displaying as expected

As a beginner front-end developer, I'm struggling to understand why the placeholder isn't functioning as expected. I attempted to use the LABEL tag, but it remains visible even when typing into the text input field. The HTML is being served via E ...

What is the process for incorporating extra classes that receive styling from a distinct CSS file?

Currently, I am utilizing both react-bootstrap and JSS concurrently, which may not be the most optimal approach. However, it is what I have been working with. I am attempting to apply a combination of Bootstrap classes while also incorporating styling thro ...

Generating documents in Word or PDF format using PHP and Angular data

My goal is to generate a Word document using PHP for which I found a solution involving the use of headers. header("Content-type: application/vnd.ms-word"); header("Content-Disposition: attachment;Filename=output.doc"); Initially, this method worked well ...

Encountering an Error when attempting to read and update with Knex.js

I am attempting to sequentially perform read and update operations. Initially, I retrieve data from the database using the id, then I modify it and aim to update the data in the database as well. However, I encounter an error stating "Unhandled rejection E ...

Arranging all text boxes in a horizontal line: A simple guide

Is there a way to align all text boxes in a single row that works properly in both IE and Chrome browsers? IE 11 display: https://i.sstatic.net/wGITo.png Chrome display: https://i.sstatic.net/jXs0r.png Textboxes are not aligned properly as shown below: ...

AngularJS location service error

My goal is to configure the login page on my master controller so that when the username and password are both set to "admin", it will redirect me to the "/tables" path. However, every time I attempt to log in, I encounter the following error: TypeError: ...

Is it possible to rearrange the node_modules directory?

Within the node_modules directory, there exists a large and extensive collection of modules. These modules are often duplicated in various sub-folders throughout the directory, with some containing identical versions while others differ by minor versions. ...

Executing the Correct Command to Import a CSV File into MongoDB using OSX Terminal

I am attempting to upload a TSV file into Mongodb, but my lack of familiarity with Terminal is causing issues. I keep receiving an error when trying to execute the following command. Can anyone provide guidance? /mongoimport --db webapp-dev --collection ...

What are some ways to expand the width of a textarea without altering the surrounding div element

Is there a way to resize a textarea using Pure CSS without affecting the structure of the table: Heading: <div class="pure-u-1 pure-u-md-1-8"> <label class="boldText">Nmbr</label> </div> <div class="pure-u-1 pure-u-md-2-5"> ...

Clicking on each link will cause the content to scroll downward

I have a fixed footer with some links. You can view it here: Check out the Codepen Demo This is the HTML code snippet: <li class="active"><a href="#">What is Facebook?</a></li> <li><a href="#abou ...

PHP email script encounters error message despite receiving a network response code of 200

I found this PHP code online and it seems to be correct, but I keep encountering an error message every time I attempt to send a test email. However, the network message indicates that the email was sent successfully. Please refer to the provided images an ...

Creating dynamic pages in Symfony using Twig template engine allows for flexible

As I embark on my journey with Symfony, I am finding that single pages work wonderfully. Having previous experience with Twig in OpenCart has helped me grasp the syntax. The documentation at https://symfony.com/doc/5.2/setup.html has been incredibly benef ...