Navigation bar fixed and absolute

CleeTorris

So what I am trying to do is a navigation bar for my website. I decided to do a transparent background with a white fond, which works perfectly with the background picture. However, I want the bar to be visible also, when you scroll down the page. Thus I choose a fixed position for the navigation bar. But then again, if you scroll down to the section where there is white background and text, the (transparent & white) navigation bar becomes unreadable.

Is it possible to code two navigation bars? So one as I have it with an absolute position with a transparent background and the white font. As soon as you start to scroll, a new navigation bar, featuring the same content, but another background (eg. orange) should pop up. If so, how do I need to code that?

Thanks a lot guys

Winterfox

I think that the easiest way to do this is with a a little bit of jQuery. Add this function:

It will create a new class that you can style your menu with.

$(window).scroll(function() {
  var scroll = $(window).scrollTop();

  if (scroll >= 900) { //Choose where on the page to add new class, here i'ts 900px from the page top
    $("nav").addClass("scrolling");
  } else {
    $("nav").removeClass("scrolling");
  }
});

CSS example:

nav {
  position: fixed;
  top: 0;
  left: 0;
  margin: 0;
  min-height: 50px;
  padding: 10px;
  background-color: transparent;
  width: 100%;
}

nav.scrolling {
  background-color: #000;
}

Check it out here: http://codepen.io/Winterfox/pen/QNrqRb

This way you don't have to create two almost exacty looking menues.

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 CSS Navigation Bar

From Dev

Navigation bar fixed after scroll?

From Dev

Fixed and Centered navigation bar, with html

From Dev

Fixed navigation bar overlap issue

From Dev

Fixed navigation bar overlap issue

From Dev

JQuery for fixed position of navigation bar

From Dev

Converting a default navigation bar into a sticky/fixed navigation bar?

From Dev

Links in Top-Fixed Navigation Bar Not Responding

From Dev

Fixed navigation bar for tablet and mobile issue

From Dev

Snapping a div to a fixed navigation bar on scroll

From Dev

Navigation bar follows scroll when fixed

From Dev

Margin not working with fixed position navigation bar

From Dev

Fixed Navigation Bar using Twitter Bootstrap 3

From Dev

How to create a fixed navigation bar iOS Swift

From Dev

Navigation bar follows scroll when fixed

From Dev

Fixed navigation bar would not work even using position: fixed in css

From Dev

Fixed side bar with slide out off canvas navigation

From Dev

How to place right side fixed navigation bar in Twitter bootstrap

From Dev

Links/hover effect not working on certain part of page in fixed navigation bar

From Dev

fixed navigation bar overlaying content when position is given dynamically

From Dev

How to make a fixed navigation bar stretch to the width of the browser?

From Dev

Prevent content from hiding behind fixed position navigation bar

From Dev

Making a header/menu bar for an off-canvas navigation menu fixed?

From Dev

Navigation bar odd behavior after giving it a fixed position in the css file

From Dev

How can I format a div into a fixed navigation bar on a webpage?

From Dev

Fixed navigation bar not overlapping some parts of my website

From Dev

Absolute and fixed positioning together

From Dev

Fixed div over absolute?

From Dev

Position absolute but with fixed scrolling

Related Related

  1. 1

    Fixed CSS Navigation Bar

  2. 2

    Navigation bar fixed after scroll?

  3. 3

    Fixed and Centered navigation bar, with html

  4. 4

    Fixed navigation bar overlap issue

  5. 5

    Fixed navigation bar overlap issue

  6. 6

    JQuery for fixed position of navigation bar

  7. 7

    Converting a default navigation bar into a sticky/fixed navigation bar?

  8. 8

    Links in Top-Fixed Navigation Bar Not Responding

  9. 9

    Fixed navigation bar for tablet and mobile issue

  10. 10

    Snapping a div to a fixed navigation bar on scroll

  11. 11

    Navigation bar follows scroll when fixed

  12. 12

    Margin not working with fixed position navigation bar

  13. 13

    Fixed Navigation Bar using Twitter Bootstrap 3

  14. 14

    How to create a fixed navigation bar iOS Swift

  15. 15

    Navigation bar follows scroll when fixed

  16. 16

    Fixed navigation bar would not work even using position: fixed in css

  17. 17

    Fixed side bar with slide out off canvas navigation

  18. 18

    How to place right side fixed navigation bar in Twitter bootstrap

  19. 19

    Links/hover effect not working on certain part of page in fixed navigation bar

  20. 20

    fixed navigation bar overlaying content when position is given dynamically

  21. 21

    How to make a fixed navigation bar stretch to the width of the browser?

  22. 22

    Prevent content from hiding behind fixed position navigation bar

  23. 23

    Making a header/menu bar for an off-canvas navigation menu fixed?

  24. 24

    Navigation bar odd behavior after giving it a fixed position in the css file

  25. 25

    How can I format a div into a fixed navigation bar on a webpage?

  26. 26

    Fixed navigation bar not overlapping some parts of my website

  27. 27

    Absolute and fixed positioning together

  28. 28

    Fixed div over absolute?

  29. 29

    Position absolute but with fixed scrolling

HotTag

Archive