Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create back-to-top button using HTML and CSS #798

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions back-to-top button using HTML and CSS
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!-- HTML File -->
<a href="#">Scroll To Top</a>

/* CSS File */
/* Basic css code for smooth scrolling */
:root { scroll-behavior: smooth; }
/* For floating back to top button */
.stt {
position: fixed;
right: 1rem;
bottom: 1rem;
width: 3rem;
height: 3rem;
border-radius: 50%;
background: rgb(128, 128, 255) url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'%3E%3Cpath fill='currentColor' d='M352 352c-8.188 0-16.38-3.125-22.62-9.375L192 205.3l-137.4 137.4c-12.5 12.5-32.75 12.5-45.25 0s-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25C368.4 348.9 360.2 352 352 352z'%3E%3C/path%3E%3C/svg%3E") center no-repeat;
box-shadow: 0 0.25rem 0.5rem 0 gray;
opacity: 0.7;
}
.stt:hover {
opacity: 0.8;
}
.stt:focus {
opacity: 0.9;
}
.stt:active {
opacity: 1;
}
/* After adding this link you have to update the HTML link by the following code
<a href='#' class="stt" title="scroll to top"></a> */
Loading