Ceangal sìnte
Dèan cliogadh air eileamaid HTML no co-phàirt Bootstrap le bhith “a’ sìneadh ”ceangal neadachaidh tro CSS.
Cuir .stretched-link
ri ceangal gus am bi am bloc anns a bheil e comasach cliogadh tro ::after
eileamaid bhrèige. Anns a’ mhòr-chuid de chùisean, tha seo a’ ciallachadh gum faodar cliogadh air eileamaid leis position: relative;
a bheil ceangal ris a’ .stretched-link
chlas. Thoir an aire leis mar a tha CSS position
ag obair , .stretched-link
chan urrainnear a mheasgachadh leis a’ mhòr-chuid de eileamaidean bùird.
Tha cairtean position: relative
ann am Bootstrap gu bunaiteach, agus mar sin anns a’ chùis seo faodaidh tu an .stretched-link
clas a chuir gu ceangal sa chairt gu sàbhailte gun atharrachadh HTML sam bith eile.
Chan eilear a’ moladh ioma-cheanglaichean agus targaidean tap le ceanglaichean sìnte. Ach, faodaidh cuid position
agus z-index
stoidhlichean cuideachadh ma bhios feum air.
Cairt le ceangal sìnte
Cuid de theacs eisimpleir sgiobalta gus togail air tiotal na cairt agus a’ mhòr-chuid de shusbaint na cairt a dhèanamh.
Rach àiteigin<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>
Chan eil a’ mhòr-chuid de cho-phàirtean gnàthaichte position: relative
mar as àbhaist, agus mar sin feumaidh sinn an .position-relative
seo a chuir ris gus casg a chuir air a’ cheangal bho bhith a’ sìneadh taobh a-muigh na h-eileamaid phàrant.
Co-phàirt gnàthaichte le ceangal sìnte
Is e seo cuid de shusbaint neach-àite airson a’ phàirt àbhaisteach. Thathas an dùil a bhith ag atharrais cò ris a bhiodh susbaint fìor san t-saoghal coltach, agus tha sinn ga chleachdadh an seo gus beagan bodhaig is meud a thoirt don phàirt.
Rach àiteigin<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>
Colbhan le ceangal sìnte
Eisimpleir eile de shusbaint neach-àite airson a’ phàirt àbhaisteach eile seo. Thathas an dùil a bhith ag atharrais cò ris a bhiodh susbaint fìor san t-saoghal coltach, agus tha sinn ga chleachdadh an seo gus beagan bodhaig is meud a thoirt don phàirt.
Rach àiteigin<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>
A 'comharrachadh a' bhloc anns a bheil
Mura h-eil coltas gu bheil an ceangal sìnte ag obair, is dòcha gur e am bloc anns a bheil e as coireach. Nì na feartan CSS a leanas eileamaid anns a’ bhloc anns a bheil:
- Luach
position
eile seachstatic
- A
transform
noperspective
luach a bharrachd airnone
- Tha
will-change
luachtransform
orperspective
filter
Luach eile seachnone
nowill-change
luachfilter
(ag obair air Firefox a-mhàin )
Cairt le ceanglaichean sìnte
Cuid de theacs eisimpleir sgiobalta gus togail air tiotal na cairt agus a’ mhòr-chuid de shusbaint na cairt a dhèanamh.
Chan obraich ceangal sìnte an seo, oir position: relative
tha e air a chur ris a’ cheangal
Cha tèid an ceangal sìnte seo a sgaoileadh ach thairis air an p
-tag, leis gu bheil cruth-atharrachaidh ga chur an sàs.
<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>