Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make a header fixed but without it being outside of flow?

So I have hero and header components in react. I made header fixed but that way it goes outside of flow, so hero components overlays it. It looks like this:
enter image description here

I want to make the header fixed, but also make it be on top of the page. The hero component’s position is static as usual.

Header css:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    @include flex(center, space-between);
    position: fixed;
    cursor: pointer;
    padding: 20px 0px;
    width:100%;
    background-color: transparent;
    height: $header-height;

Hero css:

 @include flex(center, center);
    flex-direction: column;
    width:100%;
    min-height:100vh;
    padding: 30px 0px;
    background-color: $body-bg;

I know it looks like a basic thing to do, but I can’t figure it out, I tried making header relative, but that way it’s not fixed. And making hero relative makes it overlay header.

>Solution :

Add this to nav section.

  position: sticky;
  top: 0;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading