File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 1313@import ' post-list' ;
1414
1515body {
16- padding-top : $header-height ;
16+ padding-top : $header-height ;
17+
18+ #back-to-top-button {
19+ display : none ;
20+ position : fixed ;
21+ bottom : 20px ;
22+ right : 30px ;
23+ z-index : 99 ;
24+ border : none ;
25+ outline : none ;
26+ background-color : $color-base-primary ;
27+ color : $color-text-inverted ;
28+ cursor : pointer ;
29+ padding : 15px ;
30+ border-radius : 2px ;
31+ font-size : 18px ;
32+
33+ & :hover {
34+ background-color : $color-base-hover ;
35+ }
36+ }
1737}
1838
1939footer {
Original file line number Diff line number Diff line change 1+ // Get the button:
2+ let mybutton = document . getElementById ( "back-to-top-button" ) ;
3+
4+ // When the user scrolls down 20px from the top of the document, show the button
5+ window . onscroll = function ( ) { scrollFunction ( ) } ;
6+
7+ function scrollFunction ( ) {
8+ if ( document . body . scrollTop > 20 || document . documentElement . scrollTop > 20 ) {
9+ mybutton . style . display = "block" ;
10+ } else {
11+ mybutton . style . display = "none" ;
12+ }
13+ }
14+
15+ // When the user clicks on the button, scroll to the top of the document
16+ function backToTop ( ) {
17+ document . body . scrollTop = 0 ; // For Safari
18+ document . documentElement . scrollTop = 0 ; // For Chrome, Firefox, IE and Opera
19+ }
Original file line number Diff line number Diff line change 2929< body >
3030 {% block body %} {% endblock %}
3131
32+ < button onclick ="backToTop() " id ="back-to-top-button " title ="Go to top "> Top</ button >
33+
3234 < script type ="text/javascript " src ="{{ get_url(path='elasticlunr.min.js') }} " defer > </ script >
3335 < script type ="text/javascript " src ="{{ get_url(path='api_search.js') }} " defer > </ script >
3436 < script type ="text/javascript " src ="{{ get_url(path='search.js') }} " defer > </ script >
37+ < script type ="text/javascript " src ="{{ get_url(path='back_to_top.js') }} " defer > </ script >
3538</ body >
3639
3740</ html >
You can’t perform that action at this time.
0 commit comments