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/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 Social Network to add comments!

Join Ning Creators Social Network

Email me when people reply –

Replies

  • I tried this code it didn't work for me
  • Hi dan
    Sometimes its the image link that gets broken depending how it was copied. If you leave the code in I will check it out when i get home from work. I am in the uk so it should be around 7pm uk time.
    John
  • <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/files/4gUc0nun9aa4NazU1X3bLUrQzscJcjZhQQS9UMErAdBh3uRKw3Hga846MHNbAu4wLW5fLH5VNiQaskoVXbjnBNloo*QPQQBX/IMG_0231.PNG') no-repeat ;
    background-size:50px;
    }
  • Hi Dan

    I see it is working now, I just think the codes where not added in the two different code sections but rather than all in one. It looks a nice addition to your site :-)

    John :-)

This reply was deleted.

Search the Creators Network

Latest Activity

Thisisbully replied to Thisisbully's discussion I'm losing members because of 1 silly feature
"Anything on this still have members that have no clue on how to post photos"
7 hours ago
Steve C replied to Kyryl_Ning_Support's discussion The long-awaited Search Option is now at your fingertips!
"Is there advanced search in 2.0 besides member search? I've never seen it and could really use it."
14 hours ago
Manuel Adame Jimenez replied to Yana Ning Support's discussion Video Feature on Ning 3.0 is now available!
"Hi, Kyryl, light works the way of your day, thank you, light.
☆♡☆"
15 hours ago
Kos replied to Yana Ning Support's discussion Video Feature on Ning 3.0 is now available!
"Kyryl I have to say how wonderful it is to have liaison who understands CSS/HTML.  Just love it!"
17 hours ago
Kyryl_Ning_Support replied to Yana Ning Support's discussion Video Feature on Ning 3.0 is now available!
"Hi there,
Just put this into your custom CSS code field to center the video.
.videoDetailPage-video…"
18 hours ago
Alex replied to Fabricio Giugni's discussion Powered by Ning How to get it out?
"Yes, Glam Media forced it upon us against Ning's original policy. Originally Ning communities had t…"
18 hours ago
Kos replied to Kyryl_Ning_Support's discussion Chat Feature Update on Ning 3.0 is ready!
"They told me there's nothing wrong. *lol* Wrong!"
19 hours ago
doone replied to Kyryl_Ning_Support's discussion The long-awaited Search Option is now at your fingertips!
"Thanks, it works great for me."
20 hours ago
Fabricio Giugni replied to Fabricio Giugni's discussion Powered by Ning How to get it out?
"    Be a White label is the best for creators. Force us to have they ads on our website is like ter…"
20 hours ago
Manuel Adame Jimenez replied to Yana Ning Support's discussion Video Feature on Ning 3.0 is now available!
"Hello Kyryl, I put a screen shot, to ask you to leave the video to the center or that is option to…"
20 hours ago
Alex replied to Kyryl_Ning_Support's discussion Paid Access demo version
"I find it completely astonishing that any other type of paid access could even be contemplated, whe…"
21 hours ago
Mike Collins replied to Fabricio Giugni's discussion Powered by Ning How to get it out?
"Hi Kyryl,
This was something that Glam Media brought in and it was a real sticking point for many c…"
22 hours ago
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion The long-awaited Search Option is now at your fingertips!
"Hi there!
Thanks to both of you for your suggestions to add the advanced search option.
As I see su…"
23 hours ago
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion The long-awaited Search Option is now at your fingertips!
"Hi Kos,
We are really sorry that it was necessary to wait for such a long time to see this feature…"
23 hours ago
Mike Collins replied to Kyryl_Ning_Support's discussion The long-awaited Search Option is now at your fingertips!
"Search is bringing up items from blogs/ discussions in private groups - please can this be changed…"
23 hours ago
Giovanni Cappai replied to Giovanni Cappai's discussion HTML under header not working :/
"Hi Kyryl, thanks for your reply. On firefox it works, on chrome still doesn't."
yesterday
Philip Voice replied to Kyryl_Ning_Support's discussion Chat Feature Update on Ning 3.0 is ready!
"I opened a private chat with one of my members yesterday. Nothing was typed in the chat by either o…"
yesterday
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion Paid Access demo version
"Hi there!
Thanks for your feedback it is highly appreciated.
I have updated already existing sugges…"
yesterday
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion Chat Feature Update on Ning 3.0 is ready!
"Hi there!
Thanks for useful suggestions! Some of them were completely new and some I have already p…"
yesterday
Philip Voice replied to Kyryl_Ning_Support's discussion The long-awaited Search Option is now at your fingertips!
"If anyone is interested if you want to do an off-grid search of your network (or any site) it's eas…"
yesterday
More…