abc Posted December 30, 2021 Posted December 30, 2021 (edited) Site URL: https://steven.squarespace.com/test I've created a very simple custom grid using display: grid Here's the code: <div class="grid"> <div class="grid-cell">Some Text</div> <div class="grid-cell">Some Text</div> <div class="grid-cell">Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text</div> </div> <style> .grid { width: auto; margin: 0 auto; display: grid; grid-gap: 1px; background-color: #000 !important; border: 1px solid #000 !important; grid-template-columns: repeat(3, 1fr); } .grid-cell { background-color: #fff; color: #000; padding: .5rem; min-height: 4rem; display: flex; align-items: center; justify-content: center; text-align: center !important; word-break: break-word; } </style> How do I turn each entire grid cell into a link? I tried wrapping <div class="grid-cell">Some Text</div> in anchor tags, but for some reason, it breaks the grid design. Any non-JS solutions? Thank you in advance. Edited December 31, 2021 by sqsp
Beyondspace Posted December 31, 2021 Posted December 31, 2021 22 hours ago, sqsp said: Site URL: https://steven.squarespace.com/test I've created a very simple custom grid using display: grid Here's the code: <div class="grid"> <div class="grid-cell">Some Text</div> <div class="grid-cell">Some Text</div> <div class="grid-cell">Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text</div> </div> <style> .grid { width: auto; margin: 0 auto; display: grid; grid-gap: 1px; background-color: #000 !important; border: 1px solid #000 !important; grid-template-columns: repeat(3, 1fr); } .grid-cell { background-color: #fff; color: #000; padding: .5rem; min-height: 4rem; display: flex; align-items: center; justify-content: center; text-align: center !important; word-break: break-word; } </style> How do I turn each entire grid cell into a link? I tried wrapping <div class="grid-cell">Some Text</div> in anchor tags, but for some reason, it breaks the grid design. Any non-JS solutions? Thank you in advance. Do you mean adding a link to grid cell? 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
abc Posted December 31, 2021 Author Posted December 31, 2021 49 minutes ago, bangank36 said: Do you mean adding a link to grid cell? What I would like is make the entire grid cell clickable, not just "Some Text."
Solution jpeter Posted December 31, 2021 Solution Posted December 31, 2021 @sqsp you'll need to wrap the content within the <div class="grid-cell"> in an <a> tag and add some additional styles. See the following Codepen for a working example of the code you provided. https://codepen.io/jeremypeter/pen/yLzKaaM abc 1 Full stack developer who loves helping people out with anything web related. If you'd like to support me, buy me a coffee!
abc Posted December 31, 2021 Author Posted December 31, 2021 1 hour ago, jpeter said: @sqsp you'll need to wrap the content within the <div class="grid-cell"> in an <a> tag and add some additional styles. See the following Codepen for a working example of the code you provided. https://codepen.io/jeremypeter/pen/yLzKaaM Thank you!!
Beyondspace Posted December 31, 2021 Posted December 31, 2021 (edited) 5 hours ago, sqsp said: What I would like is make the entire grid cell clickable, not just "Some Text." I think we can implement some Css code to make the a tag cover all cell. Kindly wrap the content in cell with the a tag and try the following style .grid-cell a { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; } with the style, I think we should combine with block id so your css would not affect the other element on your site Hope it makes sense Edited December 31, 2021 by bangank36 abc 1 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
abc Posted December 31, 2021 Author Posted December 31, 2021 54 minutes ago, bangank36 said: I think we can implement some Css code to make the a tag cover all cell. Kindly wrap the content in cell with the a tag and try the following style .grid-cell a { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; } with the style, I think we should combine with block id so your css would not affect the other element on your site Hope it makes sense Thank you!!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment