On my website, I have a convenient "back to top" feature that allows users to easily navigate back to the top of the page:
If you scroll down the page, you'll see this feature in action. This particular feature is part of the theme I'm using on Wordpress.
For learning purposes, I want to replicate this feature on another page of a different site. So far, I've managed to gather all the necessary components up to this point:
The issues I'm encountering are:
- The size of the box is not consistent
- The alignment of the chevron is off
- No action occurs when clicking the chevron
- The box remains visible at all times
What steps am I missing here?
Update
Following some suggestions, I have added a couple of script
lines. Here's what's currently present in the head
section:
<!-- code snippets -->
Although there has been some improvement, the issue now is that the scrolling is abrupt and not smooth. I'm puzzled as to why the JavaScript function is not being executed properly.