문제

I'm working on a huge single page website and would like to show an scroll down hint (icon or something like that) at the bottom of the window when the user visits the website.

The hint should vanish when the visitor either scrolls down or clicks on the icon. I've seen this on several websites which I can't remember now unfortunately. Already been searching on but with no results as I'm probably searching with the wrong keywords...

Anyone has any directions on where to start to achieve this?

도움이 되었습니까?

해결책

Here is a start to get the scroll hint working. Now on styling, that's up to you but I would personally do something like position: absolute and then work from there and give it a zIndex about everything on the page.

$(window).scroll( function() {
    if($(document).scrollTop() == 0 ) {
        // SHOW scroll hint
    } else {
        // HIDE scroll hint
    }
});

I did this on one of my own web pages.

http://codepen.io/pattmorter/pen/mFDLs

Just check out the javascript and the css.

다른 팁

I think you would need an ID on your icon/link and then have two event listeners. One for clicking on the ID itself and the other onscroll. Once either of those events are fired you can call .remove()

If you don't know where to start, try to read reference of window object. For visibility change you can use opacity, and position attribute to make it fixed at bottom of screen.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top