mdemartin Posted October 25, 2023 Share Posted October 25, 2023 Hi - I was wondering whether anyone knows code to make sections sticky. The sections on the following links are set to 100% heigh of any device, but I would like sections to "stick" when you scroll down - like the BBC site: https://www.bbc.co.uk/news/resources/idt-d88680d1-26f2-4863-be95-83298fd01e02 I would like to have this effect on our site: currently the page just scrolls down, whereas the BBC website section sticks until you scroll down. Thank you in advance - here is our site: https://ttc-2023.squarespace.com/index-m Password is: password Link to comment
Ziggy Posted October 25, 2023 Share Posted October 25, 2023 This is a website effect know commonly as snap-scrolling, you can add it with this script: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/scrollify/1.0.19/jquery.scrollify.min.js"></script> <script> $(function() { $.scrollify({ section: ".page-section", }); }); </script> You'll have to be careful with adding it as it fixes the height to 100vw and will hide content overflow. Please like and upvote if my comments were helpful to you. Cheers! Zygmunt Spray Squarespace Website Designer Contact me: https://squarefortytwo.com Hire me on Upwork! 🔌 Ghost Squarespace Plugins (Referral link) 📈 SEO Space (Referral link) ⬛ SquareWebsites Plugins (Referral link) 🔲 SQSP Themes (Referral link) ✨ Spark Plugin (Referral link) 🖼️ Pinch-to-Zoom Gallery Lightbox Plugin (Referral link) ☕ Did I help? Buy me a coffee? Link to comment
mdemartin Posted October 25, 2023 Author Share Posted October 25, 2023 Thanks - do I need to change the following with section ID and others followed by commas? ".page-section", Link to comment
Ziggy Posted October 25, 2023 Share Posted October 25, 2023 7 minutes ago, mdemartin said: Thanks - do I need to change the following with section ID and others followed by commas? ".page-section", Only if you want it to apply to just specific sections on a page. Please like and upvote if my comments were helpful to you. Cheers! Zygmunt Spray Squarespace Website Designer Contact me: https://squarefortytwo.com Hire me on Upwork! 🔌 Ghost Squarespace Plugins (Referral link) 📈 SEO Space (Referral link) ⬛ SquareWebsites Plugins (Referral link) 🔲 SQSP Themes (Referral link) ✨ Spark Plugin (Referral link) 🖼️ Pinch-to-Zoom Gallery Lightbox Plugin (Referral link) ☕ Did I help? Buy me a coffee? Link to comment
mdemartin Posted October 25, 2023 Author Share Posted October 25, 2023 Thanks - I would like to apply it for all sections. Does this automatically make the section heights 100% or should I use my other code for that. I did put the following in but there is an error message saying - missing opening "{" <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/scrollify/1.0.19/jquery.scrollify.min.js"></script> <script> $(function() { $.scrollify({ section: "65303804d996e5561b628174", "653930ee61ffa6ca7b58edc4”, "6532cfa94cddb24b87fc6dfc" }); }); </script> and so it doesn't appear to be working. Thank you again https://ttc-2023.squarespace.com/index-m Link to comment
tuanphan Posted October 27, 2023 Share Posted October 27, 2023 On 10/25/2023 at 10:58 PM, mdemartin said: Thanks - I would like to apply it for all sections. Does this automatically make the section heights 100% or should I use my other code for that. I did put the following in but there is an error message saying - missing opening "{" <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/scrollify/1.0.19/jquery.scrollify.min.js"></script> <script> $(function() { $.scrollify({ section: "65303804d996e5561b628174", "653930ee61ffa6ca7b58edc4”, "6532cfa94cddb24b87fc6dfc" }); }); </script> and so it doesn't appear to be working. Thank you again https://ttc-2023.squarespace.com/index-m This code should add to Code Injection, if you add to Custom CSS, it will always show miss { symbol 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
Ziggy Posted October 27, 2023 Share Posted October 27, 2023 On 10/25/2023 at 4:58 PM, mdemartin said: and so it doesn't appear to be working. Thank you again As @tuanphan said, this is a script, it's not appropriate to add to Custom CSS! Please like and upvote if my comments were helpful to you. Cheers! Zygmunt Spray Squarespace Website Designer Contact me: https://squarefortytwo.com Hire me on Upwork! 🔌 Ghost Squarespace Plugins (Referral link) 📈 SEO Space (Referral link) ⬛ SquareWebsites Plugins (Referral link) 🔲 SQSP Themes (Referral link) ✨ Spark Plugin (Referral link) 🖼️ Pinch-to-Zoom Gallery Lightbox Plugin (Referral link) ☕ Did I help? Buy me a coffee? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment