mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2024-12-22 12:13:19 -06:00
Add back to top button
This commit is contained in:
parent
0e1559f2a2
commit
161c68d16c
@ -245,6 +245,17 @@ footer {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#back-to-top {
|
||||||
|
position: fixed;
|
||||||
|
float: right;
|
||||||
|
bottom: 25px;
|
||||||
|
right: 25px;
|
||||||
|
background-color: var(--background-3);
|
||||||
|
border-radius: 100%;
|
||||||
|
padding: 12px;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Navbar formatting */
|
/* Navbar formatting */
|
||||||
@ -319,6 +330,16 @@ footer {
|
|||||||
|
|
||||||
|
|
||||||
/* Basic elements */
|
/* Basic elements */
|
||||||
|
html {
|
||||||
|
scroll-behavior: smooth;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (prefers-reduced-motion: reduce) {
|
||||||
|
html {
|
||||||
|
scroll-behavior: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background-color: var(--background);
|
background-color: var(--background);
|
||||||
color: var(--text-normal);
|
color: var(--text-normal);
|
||||||
|
8
assets/js/back-to-top.js
Normal file
8
assets/js/back-to-top.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
const backToTop = document.getElementById("back-to-top");
|
||||||
|
window.onscroll = function() {
|
||||||
|
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
|
||||||
|
backToTop.style.display = "block";
|
||||||
|
} else {
|
||||||
|
backToTop.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,8 @@
|
|||||||
{{ partial "head.html" . }}
|
{{ partial "head.html" . }}
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<a id="top"></a>
|
||||||
|
|
||||||
<div class="top">
|
<div class="top">
|
||||||
{{ partial "top.html" . }}
|
{{ partial "top.html" . }}
|
||||||
</div>
|
</div>
|
||||||
@ -26,6 +28,10 @@
|
|||||||
</small>
|
</small>
|
||||||
</footer>
|
</footer>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
<a id="back-to-top" href="#top">
|
||||||
|
{{ partial "icon.html" "chevron-up" }}
|
||||||
|
</a>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
{{ with resources.Get "css/syntax-light.css" | fingerprint "sha512" }}
|
{{ with resources.Get "css/syntax-light.css" | fingerprint "sha512" }}
|
||||||
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
|
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ with resources.Get "js/back-to-top.js" | fingerprint "sha512" }}
|
||||||
|
<script defer src="{{ .Permalink }}" type="text/javascript" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ with .Site.Params.faviconICO }}
|
{{ with .Site.Params.faviconICO }}
|
||||||
<link rel="icon" type="image/x-icon" href="{{ . | absURL }}" />
|
<link rel="icon" type="image/x-icon" href="{{ . | absURL }}" />
|
||||||
|
Loading…
Reference in New Issue
Block a user