Khechog Posted December 4, 2023 Posted December 4, 2023 Hi, I've been trying to replicate what you can see in the attached screenshot, with the icons inline with the text. Placing an image block by the text doesn't work, as they go out of alignment when the browser window is re-sized. I found some CSS for the job here https://insidethesquare.co/squarespace-tutorials/image-in-text but have had issues with the icon being cut off / not appearing / being too close to the text. I'd be quite happy to pay for a plugin for a no fuss solution - can anyone recommend one? I've been in touch with the designer who created the linked website with the example I'm trying to emulate, and she says she did it in Elementor. I'd also be up for any other solutions anyone might have! I see this done so often there must be ways and means.... Many thanks, Khechog
tuanphan Posted December 4, 2023 Posted December 4, 2023 (edited) My ideal is First, you add a Text Block > Enter Image url (here I used some random images on Pixabay) and make sure enter same image url in url box then use some code to turn image url to image, like this see a demo: https://tuanphan3.squarespace.com/icon-next-by-text?noredirect pass: abc Edited December 4, 2023 by tuanphan 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!)
tuanphan Posted December 4, 2023 Posted December 4, 2023 (edited) here is the code, you need to add it to Page Header Code Injection (DO NOT add to Custom CSS). Replace Text block id div#block....with your text block id. Use this tool to find id https://chrome.google.com/webstore/detail/squarespace-id-finder/igjamfnifnkmecjidfbdipieoaeghcff <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> $(document).ready(function(){ $('div#block-yui_3_17_2_1_1701688774020_10266 a').each(function() { var $t = $(this); $(this).contents().filter(function(){ return this.nodeType != 1; }).remove(); $t.attr({ src: $t.attr('href') }) .removeAttr('href'); $(this).replaceWith(function(){ return this.outerHTML.replace("<a", "<img").replace("</a", "</img") }); }); }); </script> <style> div#block-yui_3_17_2_1_1701688774020_10266 img { width: 40px; margin-right: 10px; } @media screen and (min-width:768px) { div#block-yui_3_17_2_1_1701688774020_10266 p { display: flex; align-items: center; } } </style> Edited December 4, 2023 by tuanphan fix an issue 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!)
Khechog Posted December 4, 2023 Author Posted December 4, 2023 Hi Tuan, I hope you're well. Maybe I'm doing something wrong, but the URL continues to show after everything's been added: https://www.meditateinthewestmidlands.co.uk/classes-2024
Solution tuanphan Posted December 4, 2023 Solution Posted December 4, 2023 21 minutes ago, Khechog said: Hi Tuan, I hope you're well. Maybe I'm doing something wrong, but the URL continues to show after everything's been added: https://www.meditateinthewestmidlands.co.uk/classes-2024 Updated above code. You can check again 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!)
Khechog Posted December 4, 2023 Author Posted December 4, 2023 That's worked, thank you. Is there a way to keep the icon small, the same height as the text? At the moment the icon fills the height of the text box which is taller than the text.
tuanphan Posted December 4, 2023 Posted December 4, 2023 Reduce width, will reduce height this code will make image - text same line (tablet + desktop only), if you want to make it run on all devices, change 767px to 1px 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!)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment