Scroll to top button?

User 495092 Photo


Registered User
259 posts

Is there a relatively easy way to add a "scroll to top" button (an arrow button or something)? Since the site I'm currently working on is basically a one-page scrolling site. I guess the other option would be to put an ID for the logo at the top and then just link an image or something back to that.
User 187934 Photo


Senior Advisor
20,271 posts

You can use a an anchor link.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 495092 Photo


Registered User
259 posts

Yeah, that's what I figured I'd have to do. What looks better? An arrow up or just text that says "Scroll to top"?
User 187934 Photo


Senior Advisor
20,271 posts

What ever you want. I've used both depending on the need.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2088758 Photo


Senior Advisor
3,121 posts

I love using the arrow up. I get mine to appear after the user starts to scroll down.
Taking over the world one website at a time!

Steve Kolish
www.misterwebguy.com

YouTube Channel:
https://www.youtube.com/channel/UCL8qVv … ttneYaMSJA
User 495092 Photo


Registered User
259 posts

Does your arrow up stay in place as the user scrolls down? If so, how do you do that? Or do you just put an arrow every so often on the page?
User 2088758 Photo


Senior Advisor
3,121 posts

I have it on two websites right now.

http://www.lucsusedequipment.com/listings.html
http://riffa.ca/

all it takes is a little custom css to my rsd file.
Taking over the world one website at a time!

Steve Kolish
www.misterwebguy.com

YouTube Channel:
https://www.youtube.com/channel/UCL8qVv … ttneYaMSJA
User 495092 Photo


Registered User
259 posts

Nice. I don't know how to do that. I'll figure something out :)
User 2088758 Photo


Senior Advisor
3,121 posts

Create another css file call it "back-to-top.css" paste the following code into it.

body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
font-size: 14px;
line-height: 150%;
background: #eee;
position: relative;
height: 100%;
}
.headerContainer,
.bodyContainer,
.footerContainer {
max-width: 960px;
margin: 0 auto;
background: #FFF;
}
.padding {
padding: 20px;
}
.bodyContainer {
min-height: 500px;
}
a.back-to-top {
display: none;
width: 60px;
height: 60px;
text-indent: -9999px;
position: fixed;
z-index: 999;
right: 20px;
bottom: 20px;
background: #62cc3e url("up-arrow.png") no-repeat center 43%;
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
border-radius: 30px;
}
a:hover.back-to-top {
background-color: #000;
}


Put it in your css folder. Then add this to your settings tab in RSD

<link rel="stylesheet" href="css/back-to-top.css">


Then create an html element near the top of your rsd page. Don't worry you will not see anything show up until you begin to scroll down on your live website. Put this in your html element:

<a class="link-text back-to-top" href="#">Linked Text</a>


Lastly add this to the footer section in RSD

// change the value with how many pixels scrolled down the button will appear
var amountScrolled = 200;

$(window).scroll(function() {
if ($(window).scrollTop() > amountScrolled) {
$('a.back-to-top').fadeIn('slow');
} else {
$('a.back-to-top').fadeOut('slow');
}
});

$('a.back-to-top, a.simple-back-to-top').click(function() {
$('body, html').animate({
scrollTop: 0
}, 'slow');
return false;
});
</script>
Taking over the world one website at a time!

Steve Kolish
www.misterwebguy.com

YouTube Channel:
https://www.youtube.com/channel/UCL8qVv … ttneYaMSJA
User 78051 Photo


Registered User
201 posts
Online Now

Its really easy to do.

Add this code to the settings 'head' section (see here http://prntscr.com/b5il5j)

<style>
a.back-to-top {
outline: 0;
display: none;
width: 60px;
height: 60px;
text-indent: -9999px;
position: fixed;
z-index: 999;
right: 20px;
bottom: 20px;
background: #000000 url("up-arrow.png") no-repeat center 43%;
opacity: 1.0;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
border-radius: 0px;
}
</style>
<script type="text/javascript">
$('body').prepend('<a href="#" class="back-to-top">Back to Top</a>');
</script>
<a href="#" class="back-to-top">Back to Top</a>

change the background colour to suit your wishes and link to where you have saved the attached up-arrow.png

now add this code to the 'Footer' section of the settings area (see here: http://prntscr.com/b5il5j)

<script type="text/Javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
var amountScrolled = 100;

$(window).scroll(function() {
if ( $(window).scrollTop() > amountScrolled ) {
$('a.back-to-top').fadeIn('slow');
} else {
$('a.back-to-top').fadeOut('slow');
}
});
</script>
<script>
$('a.back-to-top').click(function() {
$('html, body').animate({
scrollTop: 0
}, 700);
return false;
});
</script>

where 'var amountScrolled = 100; can be changed by you to reflect how many pixels (in this case 100) you need to scroll before it becomes visible

Thats it....if you need any help do let me know

Jamie
Attachments:

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.