Adding a scroll to the top button in Squarespace is a great way to improve the usability of your site. By adding this button, you can give your visitors an easy way to return to the top of your page, no matter where they are on the page. There are a few different ways that you can add this button to your Squarespace site.
One way is to use the Block ID feature. This feature allows you to add an HTML block to your page and give it an ID.
You can then use this ID to Target the block in your CSS and add the scroll to top button. To use this method, first create an HTML block and give it an ID. Then, add the following CSS to your Custom CSS:
#block-id {
position: fixed;
bottom: 20px;
right: 20px;
}
#block-id a {
display: block;
width: 40px;
height: 40px;
background-image: url("https://static1.Squarespace.com/static/5a9fe02b1f318b1f8e
cd5d5d/t/5aa0c7ebe4222d0bbfeda898/1520817646588/scroll-to-top-button.png");
background-repeat: no-repeat;
background-position: center;
}
You can also add the scroll to top button using jQuery. To do this, first include the following code in your Header Code Injection:
<script src="https://ajax.googleapis.com/ajax/libs/
jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(window).scroll(function(){
if($(this).scrollTop() > 100){
$('#scroll').fadeIn();
}
else{
$('#scroll').fadeOut();
}
});
$('#scroll').click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
</script>
Then, add the following code to your Footer Code Injection:
<div id="scroll">^</div>
<style>
#scroll {
position:fixed;
right:10px;
bottom:10px;
cursor:pointer;
display:none;
}
</style>