Red_Dot_Design Posted July 13, 2023 Posted July 13, 2023 (edited) Hello, For my sites homepage, I have created an image swap using custom CSS and code blocks. The intention of this was to replicate a title and colour opacity on hover. This function is currently not available on image blocks which is why I did it this way. This works well on desktop (screenshot attached) but on mobile it appears as per the other screenshot. My site and password: https://gopher-tomato-twpa.squarespace.com/ Password: hello The code I have used is here: //image change on hover// .image-swap { opacity: 1; max-width: 600px; /* adjust widths */ height: auto; /* adjust height */ position: relative; } .image-swap img { width: 100%; transition: all 0.2s ease; } .hovered { opacity: 0; position: absolute; left: 0; } .image-swap:hover .hovered { opacity: 1; } Thank you, Edited July 13, 2023 by Red_Dot_Design additional information added
Ziggy Posted July 13, 2023 Posted July 13, 2023 Bizarrely, this problem appears as soon as I inspect the page, no matter the screensize. Where did you get the code? 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! 📈 SEO Space (Referral link) Ⓜ️ Will Myers' Plugins & Tutorials (Referral link) 🔌 Ghost Squarespace Plugins (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?
Red_Dot_Design Posted July 13, 2023 Author Posted July 13, 2023 I got the code from here: https://originalbox.co/blog/squarespace-image-hover-effect You'll need to scroll halfway down the page to find the section titled, "Squarespace Image Change on Hover"
Ziggy Posted July 13, 2023 Posted July 13, 2023 Do you still see the same behaviour if you just have the one image/code block on the 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! 📈 SEO Space (Referral link) Ⓜ️ Will Myers' Plugins & Tutorials (Referral link) 🔌 Ghost Squarespace Plugins (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?
Red_Dot_Design Posted July 13, 2023 Author Posted July 13, 2023 I've just checked this and yes the same thing happens.
Ziggy Posted July 13, 2023 Posted July 13, 2023 Sorry, I can't really explain that. Given that you're coding this, it may be easier just to have the image and add the overlay and text in code too instead of having it in a second image, should be relatively straightforward. Red_Dot_Design 1 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! 📈 SEO Space (Referral link) Ⓜ️ Will Myers' Plugins & Tutorials (Referral link) 🔌 Ghost Squarespace Plugins (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?
Red_Dot_Design Posted July 13, 2023 Author Posted July 13, 2023 Would you be able to give me the code for adding a link and colour + title overlay to an image block?
Ziggy Posted July 13, 2023 Posted July 13, 2023 Sure thing, try this: HTML for a code block: <div class="image-overlay-container"> <a href="/portfolio"> <img class="image" src="https://images.squarespace-cdn.com/content/v1/646f55f280e63d049e7cbdd8/a567a255-0995-4be4-9092-e0a2a5cb930d/Services.png"> <div class="overlay"> <div class="text">Portfolio</div> </div> </a> </div> Custom CSS: .image-overlay-container { position: relative; } .image { display: block; width: 100%; height: auto; } .overlay { position: absolute; top: 0; bottom: 0; left: 0; right: 0; height: 100%; width: 100%; opacity: 0; transition: 600ms ease-in-out; background-color: rgb(141, 123, 119); } .image-overlay-container:hover .overlay { opacity: 0.8; } .text { color: white; font-size: 34px; position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); text-align: center; } Red_Dot_Design 1 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! 📈 SEO Space (Referral link) Ⓜ️ Will Myers' Plugins & Tutorials (Referral link) 🔌 Ghost Squarespace Plugins (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?
Red_Dot_Design Posted July 13, 2023 Author Posted July 13, 2023 Thank you, that fixed the image shifting issue and the overlay on hover looks great! 😊 The attached is what I see when it's on a mobile/tablet device (the text shows under the image instead of on hover). Is there anyway to fix this so it has the colour and title overlay as per the desktop version?
Solution Ziggy Posted July 13, 2023 Solution Posted July 13, 2023 I'm suspecting you have something on your website that is causing these issues, can you check on my test website if this code works there for you? https://quillfish-tangerine-4c2a.squarespace.com/test-layout?password=testing PW: testing Red_Dot_Design 1 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! 📈 SEO Space (Referral link) Ⓜ️ Will Myers' Plugins & Tutorials (Referral link) 🔌 Ghost Squarespace Plugins (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?
Red_Dot_Design Posted July 13, 2023 Author Posted July 13, 2023 Ah I did! I've removed the image swap code and that fixed it. You're fab, thanks so much! Ziggy 1
Ziggy Posted July 13, 2023 Posted July 13, 2023 6 minutes ago, Red_Dot_Design said: Ah I did! I've removed the image swap code and that fixed it. You're fab, thanks so much! No problem! Glad to help! 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! 📈 SEO Space (Referral link) Ⓜ️ Will Myers' Plugins & Tutorials (Referral link) 🔌 Ghost Squarespace Plugins (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?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment