Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Fade in scroll on top

  • This topic is empty.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #181582
    Romchick
    Participant

    Starting to jungle with JS / JQuery. Here is the problem:
    I want the transparent menu on top to become not transparent. I found some ideas, this one is the shortest.

    This is the style I want to change:
    \#nav-topbar.nav-container {background: rgba(0,0,0,.5); box-shadow:none;
    &.scrolled {background: rgb(255,255,255)}
    }
    <code></code>

    with this:
    $(document).ready(function() {
    $(window).scroll(function() {
    if ($(window).scrollTop() > 200) {
    $('header').addClass('scrolled');
    } else {
    $('header').removeClass('scrolled');
    };
    });
    });
    <code></code>

    Very important to change straight #nav-topbar.nav-container. As I don’t understand not a thing of this, how to handle it?

    PS The site

    #181584
    Soronbe
    Participant

    Use addClass and removeClass to add (and remove) a class to an element. Then proceed to use

    .my-new-class {
    /*css here*/
    }
    
    #181585
    Romchick
    Participant

    Its hard to understand for me now.

    What do I have to put in $(‘header’) to make it understand where to use it?

    #181602
    Paulie_D
    Member

    Perhaps you could make a Codepen.io demo…just the relevant code though. no need to recreate the whole site.

    It looks like you’re on the right track but your jQuery selector doesn’t seem to match the element in question.

    #181615
    Romchick
    Participant

    Its hard to giv the right code. Something always’s missing…
    Here’s the code but header isnt fixed… dont know why…

    #181618
    Paulie_D
    Member

    It’s not that hard..just trim away anything not related to the issue.

    We don’t need the media queries etc.

    #181622
    Romchick
    Participant

    Like this?

    But header is still isnt fixed… cant get it why…

    #181626
    Paulie_D
    Member

    Dude…seriously!

    We don’t need the menu, we don’t need the background image…just a header with a height…and the code that makes it & styles it.

    EVERYTHING ELSE CAN GO.

    If the header isn’t fixed..perhaps you haven’t applied position:fixed in your CSS.

    #181631
    Romchick
    Participant

    Let it pass. This is very hard structured template, that was chosen.

    The problem is that when I delete even one class or id the whole header disappears.

    But without knowing the php I cannot change a thing in this header, b’cuz every part in this structure is intertwined. Thats the problem. And I think I could do it wit JQ from above, but this template…. Sorry, for wasting your time. If someone else wants to help me, can give you access to site.

    #181661
    Paulie_D
    Member

    See…not hard at all

    http://codepen.io/Paulie-D/pen/wIoAz

    #181683
    Romchick
    Participant

    Thanks alot. But the thing is: its not working on my site.

    And why its not working here and here

    #181771
    Romchick
    Participant

    Yep! Guys! That was JQuery. Don’t know why, native installed JQ site doesnt see this script, after connecting straight https://ajax.googleapis.com/… it became to work. too much expirience for two days. Thanks alot! This case is closed! See you in a while. 8)

Viewing 12 posts - 1 through 12 (of 12 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.