Phobic78 Posted September 21, 2022 Posted September 21, 2022 Site URL: http://https%3Atracytredoux.com/code-test Hi, I'm trying to create a series of coloured blocks that contain an icon, a title and some text. This is the closest I have been able to get and as you can see from the code below, it's a bit messy. I have had to position the icon and the text manually, and the icon does not stay vertically centred as the screen is resized. If anyone has a suggestion how I could code this more effectively I would be very grateful. <style> .heading{ font-size:1.2em; } .text{ margin-left:60px} .imageplace{ position:absolute; top:30px } .green{ background-color:#c4e5c0; padding:20px 40px 20px 40px; border-radius:0px 20px 0px 20px; max-width: max-content; text-align:center; } </style> <div class="green"> <div class="imageplace"><img src="https://images.squarespace-cdn.com/content/v1/58762023893fc0d94810ba05/1663759321108-63ZII831I0JURY7W4V9T/guide.png?format=500w" alt="Cinque Terre" width="60" height="60"></div><div class="text"><span class="heading">At a Glance</span> – this is your daily protocol for phases 2 and 3 of the program, recipes included and some more test text to see how it resizes as i change the size of the viewport.</div> </div><br>
Beyondspace Posted September 21, 2022 Posted September 21, 2022 1 hour ago, Phobic78 said: Site URL: http://https%3Atracytredoux.com/code-test Hi, I'm trying to create a series of coloured blocks that contain an icon, a title and some text. This is the closest I have been able to get and as you can see from the code below, it's a bit messy. I have had to position the icon and the text manually, and the icon does not stay vertically centred as the screen is resized. If anyone has a suggestion how I could code this more effectively I would be very grateful. <style> .heading{ font-size:1.2em; } .text{ margin-left:60px} .imageplace{ position:absolute; top:30px } .green{ background-color:#c4e5c0; padding:20px 40px 20px 40px; border-radius:0px 20px 0px 20px; max-width: max-content; text-align:center; } </style> <div class="green"> <div class="imageplace"><img src="https://images.squarespace-cdn.com/content/v1/58762023893fc0d94810ba05/1663759321108-63ZII831I0JURY7W4V9T/guide.png?format=500w" alt="Cinque Terre" width="60" height="60"></div><div class="text"><span class="heading">At a Glance</span> – this is your daily protocol for phases 2 and 3 of the program, recipes included and some more test text to see how it resizes as i change the size of the viewport.</div> </div><br> Can you check your link again? I can not access it now BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </> 🗓️ Delivery Date Picker (Date picker form field) Gallery block 7.1 workaround </> 🤖 Ask me anything
Phobic78 Posted September 21, 2022 Author Posted September 21, 2022 4 minutes ago, bangank36 said: Can you check your link again? I can not access it now Sorry, should be: https://tracytredoux.com/code-test
Beyondspace Posted September 21, 2022 Posted September 21, 2022 Try adding to Home > Design > Custom Css .green { display: flex; align-items: center; } .green .imageplace { position: relative; display: flex; justify-content: center; align-items: center; top: 0; width: 10%; /*increase size of image*/ } .green .text { margin-left: 0; } Support me by pressing 👍 if this useful for you BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </> 🗓️ Delivery Date Picker (Date picker form field) Gallery block 7.1 workaround </> 🤖 Ask me anything
Beyondspace Posted September 21, 2022 Posted September 21, 2022 My testing BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </> 🗓️ Delivery Date Picker (Date picker form field) Gallery block 7.1 workaround </> 🤖 Ask me anything
Phobic78 Posted September 21, 2022 Author Posted September 21, 2022 4 hours ago, bangank36 said: Try adding to Home > Design > Custom Css .green { display: flex; align-items: center; } .green .imageplace { position: relative; display: flex; justify-content: center; align-items: center; top: 0; width: 10%; /*increase size of image*/ } .green .text { margin-left: 0; } Support me by pressing 👍 if this useful for you Thanks for your answer, @bangank36. It kind of works, but when the screen width gets smaller, the image becomes tiny. I'm attaching a screenshot:
tuanphan Posted September 23, 2022 Posted September 23, 2022 On 9/22/2022 at 1:25 AM, Phobic78 said: Thanks for your answer, It kind of works, but when the screen width gets smaller, the image becomes tiny. I'm attaching a screenshot: It looks fine to me. Which screen size/or device do you see problem? 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!)
Phobic78 Posted September 23, 2022 Author Posted September 23, 2022 13 minutes ago, tuanphan said: It looks fine to me. Which screen size/or device do you see problem? Thanks, @tuanphan and @bangank36, it does seem to work now. I'm not sure why the image was resizing for me before. I cleared my browser cache and restarted the laptop and it works now. The only thing is that the image aligns to the top of the container (see the screenshot). Is there any way that I can vertically align it to the centre?
tuanphan Posted September 24, 2022 Posted September 24, 2022 23 hours ago, Phobic78 said: t does seem to work now. I'm not sure why the image was resizing for me before. I cleared my browser cache and restarted the laptop and it works now. The only thing is that the image aligns to the top of the container (see the screenshot). Is there any way that I can vertically align it to the centre? Try adding this to Design > Custom CSS .imageplace { top: 50%; transform: translateY(-50%); } 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