pro Posted December 30, 2021 Share 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 Link to comment
Beyondspace Posted December 31, 2021 Share 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? Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Lightbox Studio pluginIf you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you Link to comment
pro Posted December 31, 2021 Author Share 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." Link to comment
Solution jpeter Posted December 31, 2021 Solution Share 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 pro 1 Link to comment
pro Posted December 31, 2021 Author Share 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!! Link to comment
Beyondspace Posted December 31, 2021 Share 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 pro 1 Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Lightbox Studio pluginIf you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you Link to comment
pro Posted December 31, 2021 Author Share 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!! 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