Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Administrator
m4lab_landing_page
Commits
734699a0
Commit
734699a0
authored
3 years ago
by
Rosanny Sihombing
Browse files
Options
Download
Email Patches
Plain Diff
"Go to top" button: JS and CSS
parent
530b62c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
css/m4lab.css
+16
-0
css/m4lab.css
js/generalFunction.js
+19
-1
js/generalFunction.js
with
35 additions
and
1 deletion
+35
-1
css/m4lab.css
+
16
-
0
View file @
734699a0
...
...
@@ -611,3 +611,19 @@ justify-content:space-evenly;}
.hidden
{
display
:
none
;
}
/** GO TO TOP BUTTON */
#topBtn
{
display
:
none
;
/* Hidden by default */
position
:
fixed
;
/* Fixed/sticky position */
bottom
:
20px
;
/* Place the button at the bottom of the page */
right
:
30px
;
/* Place the button 30px from the right */
z-index
:
99
;
/* Make sure it does not overlap */
border
:
none
;
/* Remove borders */
outline
:
none
;
/* Remove outline */
background-color
:
red
;
/* Set a background color */
color
:
white
;
/* Text color */
cursor
:
pointer
;
/* Add a mouse pointer on hover */
padding
:
10px
;
/* Some padding */
font-size
:
18px
;
/* Increase font size */
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
js/generalFunction.js
+
19
-
1
View file @
734699a0
...
...
@@ -17,4 +17,22 @@ function getQueryStringParams(params, url) {
var
value
=
regEx
.
exec
(
href
);
// return the value if exist
return
value
?
value
[
1
]
:
null
;
}
\ No newline at end of file
}
/** GO TO TOP Button **/
//Get the button:
var
myTopBtn
=
document
.
getElementById
(
"
topBtn
"
);
// When the user scrolls down 20px from the top of the document, show the button
window
.
onscroll
=
function
()
{
scrollFunction
()
};
function
scrollFunction
()
{
if
(
document
.
body
.
scrollTop
>
20
||
document
.
documentElement
.
scrollTop
>
20
)
{
myTopBtn
.
style
.
display
=
"
block
"
;
}
else
{
myTopBtn
.
style
.
display
=
"
none
"
;
}
}
// When the user clicks on the button, scroll to the top of the document
function
topFunction
()
{
document
.
body
.
scrollTop
=
0
;
// For Safari
document
.
documentElement
.
scrollTop
=
0
;
// For Chrome, Firefox, IE and Opera
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets