-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from Asymtode712/FloatBtnFeat
Added floating button to scroll back to top
- Loading branch information
Showing
5 changed files
with
48 additions
and
1 deletion.
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,23 @@ | ||
|
||
.scrollButton { | ||
position: fixed; | ||
bottom: 40px; | ||
right: 20px; | ||
background-color: #66BB6A; | ||
color: white; | ||
border: none; | ||
border-radius: 50%; | ||
width: 45px; | ||
height: 45px; | ||
font-size: 24px; | ||
cursor: pointer; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); | ||
transition: background-color 0.3s ease; | ||
} | ||
|
||
.scrollButton:hover { | ||
background-color: #43A047; | ||
} |
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,17 @@ | ||
import "./FloatBtn.css"; | ||
|
||
const FloatBtn = () => { | ||
const scrollToTop = () => { | ||
window.scrollTo({ | ||
top: 0, | ||
behavior: "smooth" | ||
}); | ||
}; | ||
return( | ||
<button class="scrollButton" onClick={scrollToTop}> | ||
▲ | ||
</button> | ||
); | ||
}; | ||
|
||
export default FloatBtn; |
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
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
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