Stretched Link
Make any HTML element or Bootstrap component clickable by “stretching” a nested link via CSS.
Stretched link on BootstrapExample
Add .stretched-link
to a link to make its containing block clickable via a ::after
pseudo element. In most cases, this means that an element with position: relative;
that contains a link with the .stretched-link
class is clickable.
Cards have position: relative
by default in Bootstrap, so in this case you can safely add the .stretched-link
class to a link in the card without any other HTML changes.
Multiple links and tap targets are not recommended with stretched links. However, some position
and z-index
styles can help should this be required.
Card with stretched link
Some quick example text to build on the card title and make up the bulk of the card's content.
Go somewhere<div class="card" style="width: 18rem;">
<img class="card-img-top" src="../assets/img/generic/1.jpg" alt="...">
<div class="card-body">
<h5 class="card-title">Card with stretched link</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p><a class="btn btn-primary stretched-link" href="#">Go somewhere</a>
</div>
</div>