Hla mus rau cov ntsiab lus tseem ceeb Hla mus rau docs navigation
in English

Txuas txuas

Ua ib qho HTML keeb lossis Bootstrap tivthaiv nyem tau los ntawm "stretching" qhov txuas txuas ntawm CSS.

Ntxiv .stretched-linkrau qhov txuas los ua kom nws muaj cov block clickable ntawm lub ::afterntsiab lus pseudo. Feem ntau, qhov no txhais tau hais tias ib qho khoom position: relative;uas muaj qhov txuas nrog cov .stretched-linkchav kawm yog clickable. Thov nco ntsoov muab CSS positionua haujlwm li cas , .stretched-linktsis tuaj yeem sib xyaw nrog ntau lub ntsiab lus.

Daim npav muaj position: relativelos ntawm lub neej ntawd hauv Bootstrap, yog li hauv qhov no koj tuaj yeem ruaj ntseg ntxiv cov .stretched-linkchav kawm rau qhov txuas hauv daim npav yam tsis muaj lwm yam hloov pauv HTML.

Ntau qhov txuas thiab kais lub hom phiaj tsis pom zoo nrog cov txuas txuas. Txawm li cas los xij, qee qhov positionthiab z-indexcov qauv tuaj yeem pab tau yog tias qhov no xav tau.

Card image cap
Card nrog stretched txuas

Qee cov ntawv piv txwv ceev los tsim cov npe ntawm daim npav thiab ua kom muaj ntau ntawm daim npav cov ntsiab lus.

Mus qhov twg
<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>

Feem ntau cov khoom siv kev cai tsis muaj position: relativelos ntawm lub neej ntawd, yog li peb yuav tsum tau ntxiv qhov .position-relativeno los tiv thaiv qhov txuas ntawm kev ncab sab nraud ntawm niam txiv lub caij.

Generic placeholder image
Kev cai tivthaiv nrog stretched txuas

Nov yog qee qhov chaw muab cov ntsiab lus rau qhov kev cai tivthaiv. Nws yog npaj los ua raws li qee cov ntsiab lus hauv ntiaj teb tiag tiag yuav zoo li, thiab peb siv nws ntawm no los muab cov khoom me me ntawm lub cev thiab qhov loj me.

Mus qhov twg
<div class="d-flex position-relative">
  <img src="..." class="flex-shrink-0 me-3" alt="...">
  <div>
    <h5 class="mt-0">Custom component with stretched link</h5>
    <p>This is some placeholder content for the custom component. It is intended to mimic what some real-world content would look like, and we're using it here to give the component a bit of body and size.</p>
    <a href="#" class="stretched-link">Go somewhere</a>
  </div>
</div>
Generic placeholder image
Kem nrog ncab txuas

Lwm qhov piv txwv ntawm cov ntsiab lus placeholder rau lwm qhov kev cai tivthaiv no. Nws yog npaj los ua raws li qee cov ntsiab lus hauv ntiaj teb tiag tiag yuav zoo li, thiab peb siv nws ntawm no los muab cov khoom me me ntawm lub cev thiab qhov loj me.

Mus qhov twg
<div class="row g-0 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 p-4 ps-md-0">
    <h5 class="mt-0">Columns with stretched link</h5>
    <p>Another instance of placeholder content for this other custom component. It is intended to mimic what some real-world content would look like, and we're using it here to give the component a bit of body and size.</p>
    <a href="#" class="stretched-link">Go somewhere</a>
  </div>
</div>

Txheeb xyuas qhov muaj qhov thaiv

Yog tias qhov txuas txuas tsis zoo li tsis ua haujlwm, qhov muaj qhov thaiv yuav yog qhov ua rau. Cov nram qab no CSS cov khoom yuav ua rau cov khoom muaj cov thaiv:

  • Tus positionnqi uas tsis yogstatic
  • A transformlos yog perspectivetus nqi uas tsis yognone
  • Tus will-changenqi ntawm transformlos yogperspective
  • Tus filternqi uas tsis noneyog lossis tus will-changenqi ntawm filter(tsuas yog ua haujlwm ntawm Firefox)
Card image cap
Daim npav nrog stretched txuas

Qee cov ntawv piv txwv ceev los tsim cov npe ntawm daim npav thiab ua kom muaj ntau ntawm daim npav cov ntsiab lus.

Stretched link yuav tsis ua hauj lwm ntawm no, vim position: relativeyog ntxiv rau qhov txuas

Qhov txuas txuas no tsuas yog nthuav tawm ntawm p-tag, vim tias kev hloov pauv tau siv rau nws.

<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>