Source

Na ọna asopọ

Ṣe eyikeyi eroja HTML tabi paati Bootstrap ti tẹ nipasẹ “na” ọna asopọ itẹ-ẹiyẹ nipasẹ CSS.

Ṣafikun .stretched-linksi ọna asopọ kan lati jẹ ki bulọọki ti o ni ninu rẹ tẹ nipasẹ ohun ::afterafarape kan. Ni ọpọlọpọ igba, eyi tumọ si pe ohun kan pẹlu position: relative;ti o ni ọna asopọ kan pẹlu .stretched-linkkilasi jẹ titẹ.

Awọn kaadi ni position: relativenipasẹ aiyipada ni Bootstrap, nitorinaa ninu ọran yii o le ṣafikun .stretched-linkkilasi lailewu si ọna asopọ kan ninu kaadi laisi awọn ayipada HTML miiran.

Awọn ọna asopọ pupọ ati awọn ibi-afẹde tẹ ni kia kia ko ṣe iṣeduro pẹlu awọn ọna asopọ ti o na. Sibẹsibẹ, diẹ ninu positionati z-indexawọn aza le ṣe iranlọwọ ti eyi ba nilo.

Card image cap
Kaadi pẹlu nà asopọ

Diẹ ninu awọn ọrọ apẹẹrẹ iyara lati kọ sori akọle kaadi ki o ṣe idapọ ti akoonu kaadi naa.

Lọ ibikan
<div class="card" style="width: 18rem;">
  <img src="..." class="card-img-top" 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 href="#" class="btn btn-primary stretched-link">Go somewhere</a>
  </div>
</div>

Awọn nkan media ko ni position: relativenipasẹ aiyipada, nitorinaa a nilo lati ṣafikun .position-relativeibi lati ṣe idiwọ ọna asopọ lati nina ita ohun media.

Generic placeholder image
Media pẹlu nà ọna asopọ

Cras sit amet nibh libero, ni gravida nulla. Nulla vel metus sclerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis ni faucibus.

Lọ ibikan
<div class="media position-relative">
  <img src="..." class="mr-3" alt="...">
  <div class="media-body">
    <h5 class="mt-0">Media with stretched link</h5>
    <p>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.</p>
    <a href="#" class="stretched-link">Go somewhere</a>
  </div>
</div>

Awọn ọwọn jẹ position: relativenipasẹ aiyipada, nitorinaa awọn ọwọn ti o le tẹ nikan nilo .stretched-linkkilaasi lori ọna asopọ kan. Bibẹẹkọ, nina ọna asopọ kan lori odidi .rownilo .position-staticlori ọwọn ati .position-relativeni ila.

Generic placeholder image
Awọn ọwọn pẹlu nà ọna asopọ

Cras sit amet nibh libero, ni gravida nulla. Nulla vel metus sclerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis ni faucibus.

Lọ ibikan
<div class="row no-gutters bg-light position-relative">
  <div class="col-md-6 mb-md-0 p-md-4">
    <img src="..." class="w-100" alt="...">
  </div>
  <div class="col-md-6 position-static p-4 pl-md-0">
    <h5 class="mt-0">Columns with stretched link</h5>
    <p>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.</p>
    <a href="#" class="stretched-link">Go somewhere</a>
  </div>
</div>

Idamo Àkọsílẹ ti o ni

Ti ọna asopọ ti o nà ko dabi pe o ṣiṣẹ, bulọọki ti o ni ninu yoo jasi idi. Awọn ohun-ini CSS wọnyi yoo jẹ ki eroja kan di bulọọki ti o ni ninu:

  • A positioniye miiran justatic
  • A transformtabi perspectiveiye miiran junone
  • A will-changeiye ti transformtabiperspective
  • Iye filtermiiran ju nonetabi will-changeiye kan ti filter(ṣiṣẹ nikan lori Firefox)
Card image cap
Kaadi pẹlu nà ìjápọ

Diẹ ninu awọn ọrọ apẹẹrẹ iyara lati kọ sori akọle kaadi ki o ṣe idapọ ti akoonu kaadi naa.

Na ọna asopọ yoo ko sise nibi, nitori position: relativeti wa ni afikun si awọn ọna asopọ

Ọna asopọ ti o nà yii yoo tan lori p-tag nikan, nitori pe a ti lo iyipada si rẹ.

<div class="card" style="width: 18rem;">
  <img src="..." class="card-img-top" alt="...">
  <div class="card-body">
    <h5 class="card-title">Card with stretched links</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>
    <p class="card-text">
      <a href="#" class="stretched-link text-danger" style="position: relative;">Stretched link will not work here, because <code>position: relative</code> is added to the link</a>
    </p>
    <p class="card-text bg-light" style="transform: rotate(0);">
      This <a href="#" class="text-warning stretched-link">stretched link</a> will only be spread over the <code>p</code>-tag, because a transform is applied to it.
    </p>
  </div>
</div>