Current status of the Ning Platform is always available on the Ning Status Blog.

Forum

How To Add A Scroll To Top Button

Here is a little tip for those who would like to add a scroll to top button when scrolling. There are two parts to the code, Custom Code to go in your site & Pages custom code end of page section and some CSS to go in your custom css section of the design studio.

The image will be hidden until you start scrolling down a page and then it becomes visible, then is hidden again.

Demo: If you want to see it working just head over to my site here and scroll the page: http://bizzssite.ning.com/

First of all we need to add an image into out file manager for the arrow we want to use, then copy the link for it and it to notepad or something like that to past into the code. You can use any image you want, I just did a search on google to find one, i have included the one I used here in case you want to copy that one.

A little about the CSS in case you want to change some of it.

Height and width is the size we are going to set the image to and we would also add that size for the background-size. So for example if you want the image bigger of let's say 80px then we would alter the Height to 80px, width to 80px and then also the background-size.

Position: right is the amount of margin from the right ( how far we would like to have the arrow away from the right side of the screen ) and bottom is the amount we want our arrow to come up from the bottom of the screen, so if you want the arrow a bit more nearer the right hand side and further down the screen you would alter those with lesser values and visa versa for an increased amount.

Background: This is the image we are going to use, if you just copy out the code from here then you will get the image I am using so if I change it so will yours to so it's best to add your own image to the file manager, copy it's link then replace that link in the code from mine to yours. I have made the link bold so you can see what needs to be changed.

Speed: If you want your page to scroll faster or slower then you would just need to alter the value in this line of the code(  x$('html, body').animate({scrollTop : 0},600); )   So if you want it to go faster decrease the 600 to something like 400 or if you want it to go slower then increase the value.

Increase Value = Slower  Decrease Value = Faster

1: Add Your Image And Copy The LInk

2: Copy the Custom Code To Your End Of Page Custom Code Box in site&pages

3: Copy the CSS into your Design Studio Custom CSS not forgetting to replace the image link shown in bold below.

FIRST THE CUSTOM CODE ( DO NOT COPY THIS LINE )

<a href="#" class="scrollToTop"></a>

<script>
x$(document).ready(function(){
    
    //Check to see if the window is top if not then display button
    x$(window).scroll(function(){
        if (x$(this).scrollTop() > 300) {
            x$('.scrollToTop').fadeIn();
        } else {
            x$('.scrollToTop').fadeOut();
        }
    });
    
    //Click event to scroll to top
    x$('.scrollToTop').click(function(){
        x$('html, body').animate({scrollTop : 0},600);
        return false;
    });
    
});
</script>

/** CSS CODE **/

/** SCROLL TO TOP **/

.scrollToTop{
    width:50px;
    height:50px;
    text-decoration: none;
    position:fixed;    
    right:30px;
        bottom:40px;
    display:none;
        z-index:9999;
    background: url('http://api.ning.com:80/files/BWHXRC*DO7mJDUejFCPiJYl0wQnn*Zmqqr70iN3FPx7RwSiHa3ua4gt6j7wpgeg2AqJ7QoufLxhVQKKBkAUnpjw8qdAKm2hV/scrolluparrowblue.png') no-repeat ;
        background-size:50px;
 }

Extra tip.

If you want to adjust your size of the image for smaller screens you can do so by adding this css and adjust the image size to want you want it to be.

@media only screen and ( max-width:771px ){
.scrollToTop{height:50px!important;width:50px!important;background-size:50px!important;}}

Enjoy

John :-)

You need to be a member of Ning Creators Network to add comments!

Join Ning Creators Network

Email me when people reply –

Search the Creators Network

Latest Activity

Bizz ( John ) replied to Bizz ( John )'s discussion Issue Running Scripts On Activity Feed More Items , Any Ideas How To Do This or Maybe Ning Could Help Out With A Little Info
"Thanks kyryl appreciate that"
1 hour ago
Kyryl_Ning_Support replied to Bizz ( John )'s discussion Issue Running Scripts On Activity Feed More Items , Any Ideas How To Do This or Maybe Ning Could Help Out With A Little Info
"Hi John,
Thanks for your feedback, we will forward this issue to our tech team.
Sorry for any incon…"
4 hours ago
Kyryl_Ning_Support replied to Robert Sheen's discussion why is my Ning site unavailable?
"Hi Michelle,
We have replied to you via private messages, please check.
Regards, 
Ning Team."
5 hours ago
Kyryl_Ning_Support replied to Hugh's discussion Latest on Ning and iframes?
"Hi Hugh,
Sorry for delayed response.
Your issue could be fixed pretty easily, just remove "-nocooki…"
6 hours ago
Michelle Stern replied to Robert Sheen's discussion why is my Ning site unavailable?
"I am sorry for butting in to this post but this is the only way I can post anything, I can't find h…"
7 hours ago
Michelle Stern, Brian Titus and Steve DeVore joined Ning Creators Network
7 hours ago
Hugh replied to Hugh's discussion Latest on Ning and iframes?
"Thanks for the reply. 
What I've always done is to take the YouTube code and paste it into html edi…"
yesterday
Kyryl_Ning_Support replied to Bryce Rubio's discussion A Follow-Up Message from our CEO
"Hi Kevin,
Apologies for the inconveniences and thanks for the feedback.
We have informed the manage…"
yesterday
Kyryl_Ning_Support replied to Bizz ( John )'s discussion Is This A New Feature ?
"Hi John,
We don't wish to disappoint you but this option was available before. This option is prett…"
yesterday
Kyryl_Ning_Support replied to Hugh's discussion Latest on Ning and iframes?
"Hi Hugh,
I have run the test on my test network by using the code provided by Youtube here https://…"
yesterday
Kos replied to Bryce Rubio's discussion A Follow-Up Message from our CEO
"Bryce chat, please, please, I'm grovelling, get chat released.........."
yesterday
David replied to David's discussion When are cancelled sites deleted?
"Thanks for the update, it's good to know it will eventually vanish."
yesterday
Kevin Acosta replied to Bryce Rubio's discussion A Follow-Up Message from our CEO
"Thank you for this venue to voice our issues and concerns as you plan and strategize upcoming enhan…"
yesterday
Kos replied to Hugh's discussion Latest on Ning and iframes?
"Absolutely they should.  File a ticket and get them on it.  Must be a new glitch"
yesterday
Kyryl_Ning_Support replied to Robert Sheen's discussion why is my Ning site unavailable?
"Hi there,
We have replied to you on the ticket that you have sent.
Best regards,
Ning Creators"
yesterday
Kos replied to Robert Sheen's discussion why is my Ning site unavailable?
"Sounds like they've deactivated you for some reason.  Contact them here.  Hope they get you up soon…"
yesterday
Carrie Robinson, Anthea Variend and Maureen Jansen joined Ning Creators Network
yesterday
Paul Corona replied to Robert Sheen's discussion why is my Ning site unavailable?
"we are having an issue with our site as well thought we're just getting and Unavailable message....…"
Tuesday
Bizz ( John ) replied to Bizz ( John )'s discussion How To Add A Popular Blogs Module ( ver1 )
"Thanks Kos
I will add one for forums and articles as well as it works virtually the same."
Tuesday
Kos replied to Bizz ( John )'s discussion How To Add A Popular Blogs Module ( ver1 )
"I think there are a lot of people who will love this tip.  Displaying the most popular 'anything' i…"
Tuesday
More…