Txuas txuas
Ua ib qho HTML keeb lossis Bootstrap tivthaiv nyem tau los ntawm "stretching" qhov txuas txuas ntawm CSS.
Ntxiv .stretched-link
rau qhov txuas los ua kom nws muaj cov block clickable ntawm lub ::after
ntsiab lus pseudo. Feem ntau, qhov no txhais tau hais tias ib qho khoom position: relative;
uas muaj qhov txuas nrog cov .stretched-link
chav kawm yog clickable. Thov nco ntsoov muab CSS position
ua haujlwm li cas , .stretched-link
tsis tuaj yeem sib xyaw nrog ntau lub ntsiab lus.
Daim npav muaj position: relative
los ntawm lub neej ntawd hauv Bootstrap, yog li hauv qhov no koj tuaj yeem ruaj ntseg ntxiv cov .stretched-link
chav 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 position
thiab z-index
cov qauv tuaj yeem pab tau yog tias qhov no xav tau.
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: relative
los ntawm lub neej ntawd, yog li peb yuav tsum tau ntxiv qhov .position-relative
no los tiv thaiv qhov txuas ntawm kev ncab sab nraud ntawm niam txiv lub caij.
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>
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
position
nqi uas tsis yogstatic
- A
transform
los yogperspective
tus nqi uas tsis yognone
- Tus
will-change
nqi ntawmtransform
los yogperspective
- Tus
filter
nqi uas tsisnone
yog lossis tuswill-change
nqi ntawmfilter
(tsuas yog ua haujlwm ntawm Firefox)
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: relative
yog 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>