Loading...

Creating the "Scroll to Top" with jQuery and CSS3

View: 703    Dowload: 0   Comment: 0   Post by: hanhga   Category: References   Fields: Other

Scroll to Top is a function that we usually see when scroll the page in the web have content-length, and when we see the content below will appear a button press allows us to return to the top of the content.

hiệu ứng jquery, jquery effect, Scroll to Top, thủ thuật javascript, javascript

This is a very basic function that the often used the website, so please share with you tips, to create this function for your blog or website.
First we will create the buttons as follows:

hiệu ứng jquery, jquery effect, Scroll to Top, thủ thuật javascript, javascript

Then you format the CSS for this button as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#back-top {
 
    position: fixed;
 
    bottom: 30px;
 
    margin-left: -150px;
 
}
 
 
 
#back-top a {
 
    width: 108px;
 
    display: block;
 
    text-align: center;
 
    font: 11px/100% Arial, Helvetica, sans-serif;
 
    text-transform: uppercase;
 
    text-decoration: none;
 
    color: #bbb;
 
 
 
    /* transition */
 
    -webkit-transition: 1s;
 
    -moz-transition: 1s;
 
    transition: 1s;
 
}
 
#back-top a:hover {
 
    color: #000;
 
}
 
 
 
/* arrow icon (span tag) */
 
#back-top span {
 
    width: 108px;
 
    height: 108px;
 
    display: block;
 
    margin-bottom: 7px;
 
    background: #ddd url(up-arrow.png) no-repeat center center;
 
 
 
    /* rounded corners */
 
    -webkit-border-radius: 15px;
 
    -moz-border-radius: 15px;
 
    border-radius: 15px;
 
 
 
    /* transition */
 
    -webkit-transition: 1s;
 
    -moz-transition: 1s;
 
    transition: 1s;
 
}
 
#back-top a:hover span {
 
    background-color: #777;
 
}

Finally you copy and past the following into script inside the tag or the tag

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
 
 
 
<script>
 
$(document).ready(function(){
 
 
 
    // hide #back-top first
 
    $("#back-top").hide();
 
 
 
    // fade in #back-top
 
    $(function () {
 
        $(window).scroll(function () {
 
            if ($(this).scrollTop() > 100) {
 
                $('#back-top').fadeIn();
 
            } else {
 
                $('#back-top').fadeOut();
 
            }
 
        });
 
 
 
        // scroll body to 0px on click
 
        $('#back-top a').click(function () {
 
            $('body,html').animate({
 
                scrollTop: 0
 
            }, 800);
 
            return false;
 
        });
 
    });
 
 
 
});
 
</script>
In some browsers if Javascript is not supported then you insert id = "top" on the right side of the card to function can run. If you have any questions then don't hesitate to leave a message in the form of comments.

Creating the "Scroll to Top" with jQuery and CSS3

Scroll to Top is a function that we usually see when scroll the page in the web have content-length, and when we see the content below will appear a button press allows us to return to the top of the content.

Posted on 30-06-2015 

Comment:

To comment you must be logged in members.

Files with category

  • Instructions for installing and configuring Windows Live Mail on Windows 10 simple

    Instructions for installing and configuring Windows Live Mail on Windows 10 simple

    View: 3379    Download: 0   Comment: 0

    Category: References     Fields: Other

    Windows 10 pre-installed Mail application for managing personal email on the device. The latest version of this application but improved a lot and support other email accounts such as Gmail or Yahoo Mail but users almost no "salty" really with this...

  • Step by step instructions to create social networking buttons with CSS3

    Step by step instructions to create social networking buttons with CSS3

    View: 2354    Download: 0   Comment: 0

    Category: References     Fields: Other

    CSS3 help web designers have the ability to create buttons (buttons) very nice, today I will share with you two tips decoration for button in your web becomes radiant beauty that no need to use photoshop.

  • You should understand the CSS Box Shadow

    You should understand the CSS Box Shadow

    View: 2435    Download: 0   Comment: 0

    Category: References     Fields: Other

    Effects his shadow was introduced in the previous article, however, in this article, I will guide more specific about shadow attributes, you try it with anything. First we try to learn css following paragraph:

  • How to do button movement with beautiful CSS3

    How to do button movement with beautiful CSS3

    View: 2120    Download: 0   Comment: 0

    Category: References     Fields: Other

    Previously to create motion effects button, you must draw the button in photoshop, then switched to flash to make it possible to move. But now you need not spend too much time doing it, all because of the emergence of CSS3.

  • Create a dropdown menu with CSS3 effects with beautiful transtions

    Create a dropdown menu with CSS3 effects with beautiful transtions

    View: 2327    Download: 0   Comment: 0

    Category: References     Fields: Other

    More of the dropdown menu you want to introduce to you, this will have the effect menu transitions (converted background of menu background from pale to dark). This menu works well on browsers like FF, Chrome, Safary, but unfortunately did not work...

  • How to hack css for all browsers you should know

    How to hack css for all browsers you should know

    View: 1920    Download: 0   Comment: 0

    Category: References     Fields: Other

    In the process of web design, which makes it the most headaches is how to design web pages that you can run on the browser. Especially when clients use the old as IE6 browser such. However, with this article, you will easily edit interface runs well...

  • Create Accordion with extremely beautiful CSS3

    Create Accordion with extremely beautiful CSS3

    View: 2430    Download: 0   Comment: 0

    Category: References     Fields: Other

    Accordion is a technique that helps you shortened the content that you want displayed on the website. It is often used for the display of submenus. In addition you can also use it for content, images. Before applying this procedure, you have to use...

  • Create the effect Hovercho images with Webkit and CSS3 is great

    Create the effect Hovercho images with Webkit and CSS3 is great

    View: 2052    Download: 0   Comment: 0

    Category: References     Fields: Other

    WebKit is one open source application framework provides the necessary components built one for your web browser. Along with CSS3, cả have contributed to very nice effect những previously only using JavaScript or JQuery thực beige.​

 
File suggestion for you
Loading...
File top downloads
Loading...
Loading...
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd