Forums

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

Home Forums CSS CSS scrolling working example, but not when implemented

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #247139
    rbfmnpwr
    Participant

    Hi, Yeah… Me again. Sorry to bother you again :-P

    Losing my common sense here. I am having troubles implementing the example, and I just can’t see what the difference is between that and my own page.

    I am fairly positive, that it is because I just lack the knowledge to do so.

    Example:
    https://codepen.io/anon/pen/JRVGvV

    My page:
    https://codepen.io/anon/pen/amAYEp

    As you can see in the example, the page is scrolling to an anchor (?) upon activation. I tried to dublicate this effect on my own site. But something is wrong, and I just cant see what the problem is. The scrolling is simple not there.

    #247146
    Shikkediel
    Participant

    It is because this selector doesn’t match:

    a[ id= "home" ]:target ~ #contentDiv div.content {
    

    Where #contentDiv is referred to as the sibling (~) but it isn’t, the element #masterDiv is.

    #247180
    rbfmnpwr
    Participant

    Aaah, I see….

    So I should change the ~ into a > or just a space?

    #247181
    Shikkediel
    Participant

    You’ll still need the ~ selector, I think easiest would be to just substitute #contentDiv for #masterDiv.

    a[ id= "home" ]:target ~ #masterDiv div.content {
    
    #247182
    Shikkediel
    Participant

    Have a look at this by the way, it’ll make the translate responsive and you won’t have to calculate and change any fixed sizes:

    Demo

    a[id="home"]:target ~ #masterDiv div.content {
      -webkit-transform: translateY(0);
      transform: translateY(0);
    }
    
    a[id="about"]:target ~ #masterDiv div.content {
      -webkit-transform: translateY(-100%);
      transform: translateY(-100%);
    }
    
    a[id="background"]:target ~ #masterDiv div.content {
      -webkit-transform: translateY(-200%);
      transform: translateY(-200%);
    }
    
    ...
    
    #247214
    rbfmnpwr
    Participant

    I love this forum! Thanks!

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