char777
-
Posts
2 -
Joined
-
Last visited
Content Type
Forums
Gallery
Blogs
Events
Store
Downloads
Profiles
Posts posted by char777
-
-
On 3/8/2013 at 7:39 AM, HammaadM said:
Edit the Footer
- Go to your site’s footer area – see How do I add content to the Footer of my site?
- Add a Code Block
- Make sure it’s set to HTML and the Display Source option is unchecked
- Add this code: <a href="#" class="scrollup">Scroll</a>
If you don’t want any animation just leave it at this, but if you want some fading animation carry on following along!
CSS Editor
Go to the CSS Editor – to see how to get to it, take a look at Using the CSS Editor.
Paste in the following:
.scrollup { width: 40px; height: 40px; opacity: 0.3; position: fixed; bottom: 50px; right: 100px; display: none; text-indent: -9999px; background: url('icon_top.png') no-repeat; }
Replace icon_top.png with your scroll up button and you can mess with the exact positioning with the values for right and bottom i.e. increasing the value for right to 110px will mean the icon will be 110px from the right edge of the screen.
Page Header Code Injection
Paste this into your site’s Page Header Code Injection, for how to get to it see the article Using Code Injection:
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> <script> $(document).ready(function () { $(window).scroll(function () { if ($(this).scrollTop() > 100) { $('.scrollup').fadeIn(); } else { $('.scrollup').fadeOut(); } }); $('.scrollup').click(function () { $("html, body").animate({ scrollTop: 0 }, 600); return false; }); }); </script>
Working Example
You can see it in action in this JSFiddle – Scroll to top.
Hope this helps.
On 3/8/2013 at 7:39 AM, HammaadM said:Edit the Footer
- Go to your site’s footer area – see How do I add content to the Footer of my site?
- Add a Code Block
- Make sure it’s set to HTML and the Display Source option is unchecked
- Add this code: <a href="#" class="scrollup">Scroll</a>
If you don’t want any animation just leave it at this, but if you want some fading animation carry on following along!
CSS Editor
Go to the CSS Editor – to see how to get to it, take a look at Using the CSS Editor.
Paste in the following:
.scrollup { width: 40px; height: 40px; opacity: 0.3; position: fixed; bottom: 50px; right: 100px; display: none; text-indent: -9999px; background: url('icon_top.png') no-repeat; }
Replace icon_top.png with your scroll up button and you can mess with the exact positioning with the values for right and bottom i.e. increasing the value for right to 110px will mean the icon will be 110px from the right edge of the screen.
Page Header Code Injection
Paste this into your site’s Page Header Code Injection, for how to get to it see the article Using Code Injection:
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> <script> $(document).ready(function () { $(window).scroll(function () { if ($(this).scrollTop() > 100) { $('.scrollup').fadeIn(); } else { $('.scrollup').fadeOut(); } }); $('.scrollup').click(function () { $("html, body").animate({ scrollTop: 0 }, 600); return false; }); }); </script>
Working Example
You can see it in action in this JSFiddle – Scroll to top.
Hope this helps.
This solution is very helpful!
However, it didn't work when I put on my site at first time, I spend a lot of time finding the problems and here are two points should be noticed:
1. add a sentence: " z-index: 1!important;" into the CSS code!
(Otherwise the button might only display on places that near the footer )
2. check the image url, make sure it is a full link like https://abc.com/s/button.jpg rather than /s/button.jpg!
Otherwise only if you open the CSS editor can you see the button
Question for adding scroll up button
in Customize with code
Posted
Site URL: https://www.yichongz.com/
.scrollup { width: 48px; height: 48px; opacity: 0.8; position: fixed!important; bottom: 20px; right: 40px; z-index: 1; display: none; text-indent: -9999px; }
I used the code like this, and insert the block into the footer.
But the problem is, I want the scroll up button float and fixed on the screen, but if I put the block in the footer, it just stays in the area of the footer.
I tried adding a block outside of the future and those codes work well. However, I don't want to insert new block in every page. Does anyone know how to deal with the blocks in the footer?
BTW, I've used these codes for a long time, and everything looks good when I first implemented it. Did the Squarespace upgraded these days?