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>
Cov khoom siv xov xwm 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 los ntawm kev ncab sab nraum cov khoom siv xov xwm.
Media nrog stretched txuas
Nov yog qee qhov chaw muab cov ntsiab lus rau cov khoom siv xov xwm. 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="media position-relative">
<img src="..." class="mr-3" alt="...">
<div class="media-body">
<h5 class="mt-0">Media with stretched link</h5>
<p>This is some placeholder content for the media object. 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>
Cov kab yog position: relative
los ntawm lub neej ntawd, yog li cov kab clickable tsuas yog xav tau cov .stretched-link
chav kawm ntawm qhov txuas. Txawm li cas los xij, ncab ib qhov txuas hla ib qho tag nrho .row
yuav tsum muaj .position-static
nyob rau hauv kab thiab .position-relative
ntawm kab.
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 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>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>