Adding a "scroll to top" button
A "scroll to top" button is a must-have element on the sites that have more than 3 blocks. It provides visitors who land on the site with a pleasant navigation experience and makes it easier for them to surf through your website.
- Here's how the button can look like:
- For that, open the site Settings and proceed to the Custom code tab:
Insert the following line of code in the Before section.
- After that, you should add scripts for the button initialization and activation. For that, add the first following script before the previous line of code in the Before section as well:
- Now, add the second script to the tab:
- To finish the integration, style your button with CSS styles. You can style the button however you want, but the easiest way is to use our given code snippet. Copy the following CSS properties and paste them in the CSS tab:
_#myBtn { width: 40px; line-height: 40px; overflow: hidden; z-index: 999; cursor: pointer; opacity:0; transition: all 0.4s ease-in; -o-transition: all 0.4s ease-in; -webkit-transition: all 0.4s ease-in; -moz-transition: all 0.4s ease-in; position: fixed; bottom: 50px; right: 0; background-color: #ededed; color: #5FC7AE; text-align: center; font-size: 40px; font-weight:bold; text-decoration: none; box-shadow: 0px 0px 10px rgba(0,0,0,0.3); } #myBtn:hover { background-color: #5FC7AE; color: #fff; _
- Click on the Save button for changes to appear live.
Updated on: 04/13/2023
Thank you!