Website Content disappearing behind fixed navbar with margin-top when scrolling

Nico J

I'm trying to build a fixed navbar with a margin-top on top of a website which has a background texture. I'd like the content of the website to be hidden but the navbar when scrolling down but I want to keep this empty margin-top the all time. Here is the over simple html:

<nav>
    My Fixed navbar with margin on top
</nav>
<div id="content">
    My content that shouldn't apppear in the margin-top of the navbar
</div>

I have made a jfiddle to explain my problem: https://jsfiddle.net/nicoj/ttL3mp4r/8/

Basically the content is hiding behind the navbar when scrolling down which is cool but is reappearing above it after...

What I would like to do is to prevent the content from reappearing above the navbar: Keeping the navbar and the background image on top the whole time. I was thinking of having the #content fixed too with an overflow: scroll but then the scrollbar is embedded inside the content which I don't want.

I feel like I'm missing something simple here... I hope you have any tips!

Nico

Fester

Considering the fact that your background is fixed as well, there's a pretty quick and easy way to solve this:

HTML

<div id="overlay">  
</div>
<nav>
    fixed navbar
</nav>
<div id="content">
    My content that should not appear above the navbar
</div>

CSS

#overlay {
   position: fixed;
    background-image: url("http://allroundnews.com/wp-content/uploads/2012/02/seamless-wood-texture-free-76.jpg");
    width: 100%;
    height: 50px;
    margin: 0;
    top: -20px;
    margin-left: auto;
    margin-right: auto;
}

Fiddle

I'm sure there are better ways to solve this, but this seemed like an easy fix for a simple issue.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Fixed navbar falls behind content

From Dev

change navbar-fixed-top color when scrolling

From Dev

Why is the body being hidden behind navbar when i use navbar-fixed-top

From Dev

In css, when I extend the top margin of my main content, my fixed top nav section margin drops along with the main content

From Dev

fixed page, content scrolling behind header

From Dev

Bootstrap fixed to top navbar covering website

From Dev

Navbar Fixed To top without content under

From Dev

debug lag of calculate margin top for Position fixed sidebar scrolling to bottom

From Dev

How to achieve content overlap when expanding (collapsing) menu with navbar-static-top (similar to navbar-fixed-top behavior)

From Dev

Navbar stick to top of screen when scrolling past

From Dev

Scrolling past top with fixed navbar behaving differently across different browsers

From Dev

Twitter Bootstrap 3 - Navbar Fixed Top - Overlaps content when multiple lines

From Dev

Twitter Bootstrap 3 - Navbar Fixed Top - Overlaps content when multiple lines

From Dev

Table header to stay fixed at the top when scrolling

From Dev

CSS Positioning: Fixed Left or Top when scrolling

From Dev

Make menu bar fixed on top when scrolling

From Dev

Content is half hidden underneath fixed header, despite changing 'top' margin

From Dev

Offset content top margin based on height of fixed header

From Dev

Offset content top margin based on height of fixed header

From Dev

H1 and site content disappearing through banner as if they have a negative top margin

From Dev

How to put content above navbar-fixed-top?

From Dev

Bootstrap 3 navbar-fixed-top overlaps with content

From Dev

Bootstrap navbar-fixed-top hiding page content

From Dev

dynamic bootstrap 3 navbar fixed top overlapping content

From Dev

Bootstrap 3 navbar-fixed-top overlaps with content

From Dev

Bootstrap 3 Fixed Top Navbar 'Flickering' On Mobile Scrolling using jQuery One-Page Scrolling Effect

From Dev

Fixed navbar covered by rest of the page when scrolling down

From Dev

fixed div is getting margin top

From Dev

Header is disappearing when the position is fixed

Related Related

  1. 1

    Fixed navbar falls behind content

  2. 2

    change navbar-fixed-top color when scrolling

  3. 3

    Why is the body being hidden behind navbar when i use navbar-fixed-top

  4. 4

    In css, when I extend the top margin of my main content, my fixed top nav section margin drops along with the main content

  5. 5

    fixed page, content scrolling behind header

  6. 6

    Bootstrap fixed to top navbar covering website

  7. 7

    Navbar Fixed To top without content under

  8. 8

    debug lag of calculate margin top for Position fixed sidebar scrolling to bottom

  9. 9

    How to achieve content overlap when expanding (collapsing) menu with navbar-static-top (similar to navbar-fixed-top behavior)

  10. 10

    Navbar stick to top of screen when scrolling past

  11. 11

    Scrolling past top with fixed navbar behaving differently across different browsers

  12. 12

    Twitter Bootstrap 3 - Navbar Fixed Top - Overlaps content when multiple lines

  13. 13

    Twitter Bootstrap 3 - Navbar Fixed Top - Overlaps content when multiple lines

  14. 14

    Table header to stay fixed at the top when scrolling

  15. 15

    CSS Positioning: Fixed Left or Top when scrolling

  16. 16

    Make menu bar fixed on top when scrolling

  17. 17

    Content is half hidden underneath fixed header, despite changing 'top' margin

  18. 18

    Offset content top margin based on height of fixed header

  19. 19

    Offset content top margin based on height of fixed header

  20. 20

    H1 and site content disappearing through banner as if they have a negative top margin

  21. 21

    How to put content above navbar-fixed-top?

  22. 22

    Bootstrap 3 navbar-fixed-top overlaps with content

  23. 23

    Bootstrap navbar-fixed-top hiding page content

  24. 24

    dynamic bootstrap 3 navbar fixed top overlapping content

  25. 25

    Bootstrap 3 navbar-fixed-top overlaps with content

  26. 26

    Bootstrap 3 Fixed Top Navbar 'Flickering' On Mobile Scrolling using jQuery One-Page Scrolling Effect

  27. 27

    Fixed navbar covered by rest of the page when scrolling down

  28. 28

    fixed div is getting margin top

  29. 29

    Header is disappearing when the position is fixed

HotTag

Archive