Skwolven Posted September 17, 2020 Share Posted September 17, 2020 Site URL: https://fredfilms.com Hi, My website has a scrolling index/homepage with multiple 'blank' pages nested. I added a banner image to the top page with a text overlay and would like that banner image to randomly load each time someone visits the page. Any help would be greatly appreciated! Link to comment
Skwolven Posted September 22, 2020 Author Share Posted September 22, 2020 nevermind! I got it to work by taking the image out of the banner and setting background properties with CSS. I've seen some other folks struggling with this so here's what worked for me: CSS #page{ background: #cacaca; background-attachment: fixed; background-position: center; background-repeat: no-repeat; background-size: cover; background-blend-mode: multiply; } -style your background however you want. I like the parallax effect and added an overlay so the text on top would stand out more footer code injection: <script type="text/javascript"> var images = ['image.jpg', 'image2.jpg', 'image3.jpg', 'image4.jpg', 'image5.jpg']; document.getElementById("page").style.backgroundImage = 'url(" ' + images[Math.floor(Math.random() * images.length)] + '")'; </script> -you'll have to find the urls for your images and replace image.jpg above with the full url, and replace "page" with whatever your page id is. good luck! Link to comment
rGRAYphotog Posted January 10, 2022 Share Posted January 10, 2022 (edited) @Skwolven Thank you for sharing your script. Would the script work with random background videos? Edited January 10, 2022 by rGRAYphotog Link to comment
AndrejB Posted August 28, 2022 Share Posted August 28, 2022 @Skwolven Thanks for sharing the script. I'm trying to implement it on SQSP 7.1 with no luck. Can someone help? Link to comment
tuanphan Posted August 29, 2022 Share Posted August 29, 2022 14 hours ago, AndrejB said: @Skwolven Thanks for sharing the script. I'm trying to implement it on SQSP 7.1 with no luck. Can someone help? You want this for Banner Image or Banner Video? With banner image, I remember I solved a similar case. Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
rGRAYphotog Posted February 24 Share Posted February 24 On 8/29/2022 at 3:07 AM, tuanphan said: You want this for Banner Image or Banner Video? With banner image, I remember I solved a similar case. @tuanphan Do you have the solution to do random banner image in 7.1? Thank you 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