forked from OtacilioN/awesome-hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create back-to-top button using HTML and CSS
Fixes OtacilioN#790 Created a back to top button code using HTML and CSS. Also added code for floating back to top button. Hope this solves the issue. Looking forward for merging this PR.
- Loading branch information
1 parent
b532977
commit 5350889
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> */ |