Skip to content

Instantly share code, notes, and snippets.

@bartveneman
Created December 25, 2023 20:10
Show Gist options
  • Save bartveneman/c2b828dcd63340177e12a5100041ac7b to your computer and use it in GitHub Desktop.
Save bartveneman/c2b828dcd63340177e12a5100041ac7b to your computer and use it in GitHub Desktop.
Fully clickable element with link inside
/**
* Make entire parent clickable from a link within:
*
* <element class="coverable">
* <a class="coverable-link" href="https://example.com">Example</a>
* <img src="https://example.com/image.jpg">
* </element>
*/
.coverable {
position: relative;
}
.coverable-link::after {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment