Jump to content

Back to top floating button

Recommended Posts

  • 2 weeks later...
  • 8 months later...

You can try replacing this code with your SVG element

image.thumb.png.b358718276aa40eca491c2d119750e96.png

For the PNG, you can upload your image on Home > Design > Custom Css then get the URL and use it as a background or use pseudo-element to achieve your target

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment
  • 6 months later...

Hi I know this is an old post, but this is exactly what I am trying to do so I hope you can help me.
The code I have used from this thread and included in the code-injection is as follows:
Everything placement wise, size etc is perfect, just changing it to the PNG is hurting my head :S

Anything you can help with would be amazing.

<style>
    #myBtn {
       width: 50px;
       height: 50px;
       display: none;
       position: fixed;
       bottom: 20px;
       right: 30px;
       z-index: 99;
       border: #ff2e00;
       outline: #aeaeae;
       font-size: 25px !important;
       color: #ff2e00;
       cursor: pointer;
       padding: 10px 10px 10px 11px;
       border-radius: 50%;
       box-shadow: 0px 0px 0px #000;
       background-color: none;
    }

  
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/js/all.min.js" crossorigin="anonymous"></script>
<button onclick="topFunction()" id="myBtn" title="Go to top">
    <i class="fas fa-angle-up"></i>
</button>
<script>
   window.onscroll = function() {scrollFunction()};

   function scrollFunction() {
      if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
         document.getElementById("myBtn").style.display = "block";
      } else {
         document.getElementById("myBtn").style.display = "none";
      }
   }

   function topFunction() {
      $('html,body').animate({ scrollTop: 0 }, 1000);
   }
</script>

 

And the link I used to change the button is below https://static1.squarespace.com/static/643d1f745d3d3e36eeeb21a4/t/6502f57070c57d17c0564302/1694692720913/Arrow+button+-+Up.png  

Can you let me know how I need to amend the code above to make this the 'back to top' button?

Thanks!

P

Link to comment
On 9/14/2023 at 7:07 PM, PWinter said:

Hi I know this is an old post, but this is exactly what I am trying to do so I hope you can help me.
The code I have used from this thread and included in the code-injection is as follows:
Everything placement wise, size etc is perfect, just changing it to the PNG is hurting my head :S

Anything you can help with would be amazing.

<style>
    #myBtn {
       width: 50px;
       height: 50px;
       display: none;
       position: fixed;
       bottom: 20px;
       right: 30px;
       z-index: 99;
       border: #ff2e00;
       outline: #aeaeae;
       font-size: 25px !important;
       color: #ff2e00;
       cursor: pointer;
       padding: 10px 10px 10px 11px;
       border-radius: 50%;
       box-shadow: 0px 0px 0px #000;
       background-color: none;
    }

  
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/js/all.min.js" crossorigin="anonymous"></script>
<button onclick="topFunction()" id="myBtn" title="Go to top">
    <i class="fas fa-angle-up"></i>
</button>
<script>
   window.onscroll = function() {scrollFunction()};

   function scrollFunction() {
      if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
         document.getElementById("myBtn").style.display = "block";
      } else {
         document.getElementById("myBtn").style.display = "none";
      }
   }

   function topFunction() {
      $('html,body').animate({ scrollTop: 0 }, 1000);
   }
</script>

 

And the link I used to change the button is below https://static1.squarespace.com/static/643d1f745d3d3e36eeeb21a4/t/6502f57070c57d17c0564302/1694692720913/Arrow+button+-+Up.png  

Can you let me know how I need to amend the code above to make this the 'back to top' button?

Thanks!

P

You mean replace back to top arrow icon in the code with your custom image?

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
On 9/19/2023 at 5:04 PM, PWinter said:

Yes that's correct. Thank you.

Add this code under. If it doesn't work, please share site url, we can check easier

<style>
  #myBtn i {
  	visibility: hidden;
  }
  #myBtn {
  	background-image: url(https://static1.squarespace.com/static/643d1f745d3d3e36eeeb21a4/t/6502f57070c57d17c0564302/1694692720913/Arrow+button+-+Up.png);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
  }
</style>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.