Rabhaidhean
Thoir seachad teachdaireachdan fios air ais co-theacsail airson gnìomhan àbhaisteach luchd-cleachdaidh leis an dòrlach de theachdaireachdan rabhaidh sùbailte a tha rim faighinn.
Tha rabhaidhean rim faighinn airson fad teacsa sam bith, a bharrachd air putan cuir às do roghainn. Airson stoidhle ceart, cleachd aon de na h-ochd clasaichean co-theacsail a tha a dhìth (me, .alert-success
). Airson cuir às do dhreuchd in-loidhne, cleachd am plugan rabhaidhean jQuery .
<div class="alert alert-primary" role="alert">
This is a primary alert—check it out!
</div>
<div class="alert alert-secondary" role="alert">
This is a secondary alert—check it out!
</div>
<div class="alert alert-success" role="alert">
This is a success alert—check it out!
</div>
<div class="alert alert-danger" role="alert">
This is a danger alert—check it out!
</div>
<div class="alert alert-warning" role="alert">
This is a warning alert—check it out!
</div>
<div class="alert alert-info" role="alert">
This is a info alert—check it out!
</div>
<div class="alert alert-light" role="alert">
This is a light alert—check it out!
</div>
<div class="alert alert-dark" role="alert">
This is a dark alert—check it out!
</div>
A’ toirt brìgh do theicneòlasan cuideachail
Chan eil a bhith a’ cleachdadh dath gus brìgh a chur ris ach a’ toirt seachad sealladh lèirsinneach, nach tèid a thoirt do luchd-cleachdaidh theicneòlasan taice - leithid leughadairean sgrion. Dèan cinnteach gu bheil fiosrachadh air a chomharrachadh leis an dath an dàrna cuid follaiseach bhon t-susbaint fhèin (me an teacsa faicsinneach), no air a thoirt a-steach tro dhòighean eile, leithid teacsa a bharrachd falaichte leis a’ .sr-only
chlas.
Cleachd an .alert-link
clas goireis gus ceanglaichean dathte a thoirt seachad gu sgiobalta taobh a-staigh rabhadh sam bith.
<div class="alert alert-primary" role="alert">
This is a primary alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-secondary" role="alert">
This is a secondary alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-success" role="alert">
This is a success alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-danger" role="alert">
This is a danger alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-warning" role="alert">
This is a warning alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-info" role="alert">
This is a info alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-light" role="alert">
This is a light alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert alert-dark" role="alert">
This is a dark alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
Faodaidh eileamaidean HTML a bharrachd a bhith ann an rabhaidhean mar cinn, paragrafan agus luchd-sgaraidh.
S math a rinn thu!
Aww yeah, tha thu air an teachdaireachd rabhaidh chudromach seo a leughadh gu soirbheachail. Tha an teacsa eisimpleir seo gu bhith a’ ruith beagan nas fhaide gus am faic thu mar a tha farsaingeachd taobh a-staigh rabhadh ag obair leis an t-seòrsa susbaint seo.
Nuair a dh’ fheumas tu, bi cinnteach gun cleachd thu goireasan iomaill gus cùisean a chumail snog is sgiobalta.
<div class="alert alert-success" role="alert">
<h4 class="alert-heading">Well done!</h4>
<p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
<hr>
<p class="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
</div>
Le bhith a’ cleachdadh am plugan rabhadh JavaScript, tha e comasach cuir às do rabhadh in-loidhne sam bith. Seo mar a tha:
- Dèan cinnteach gu bheil thu air am plugan rabhaidh, no am Bootstrap JavaScript a chuir ri chèile.
- Ma tha thu a’ togail ar JavaScript bhon tùs, feumaidh
util.js
e . Tha an dreach cruinnichte a’ toirt a-steach seo. - Cuir putan cuir às agus an
.alert-dismissible
clas, a chuireas pleadhag a bharrachd air taobh deas an rabhaidh agus a chuireas am.close
putan air dòigh. - Air a’ phutan cuir às, cuir am
data-dismiss="alert"
feart ris, a bhrosnaicheas gnìomhachd JavaScript. Dèan cinnteach gun cleachd thu an<button>
eileamaid leis airson giùlan ceart thar gach inneal. - Gus rabhaidhean a bheothachadh nuair a thèid an cur às, bi cinnteach gun cuir thu na clasaichean
.fade
agus na.show
clasaichean ris.
Chì thu seo ann an gnìomh le demo beò:
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>Holy guacamole!</strong> You should check in on some of those fields below.
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
Dèan comas air rabhadh a chuir às tro JavaScript:
No le data
buadhan air putan taobh a-staigh an rabhaidh , mar a chithear gu h-àrd:
Thoir an aire gun toir dùnadh rabhadh air falbh e bhon DOM.
Dòigh-obrach | Tuairisgeul |
---|---|
$().alert() |
A’ toirt rabhadh ag èisteachd airson tachartasan cliog air eileamaidean sliochd aig a bheil am data-dismiss="alert" feart. (Chan eil sin riatanach nuair a thathar a’ cleachdadh fèin-thòiseachadh data-api.) |
$().alert('close') |
A’ dùnadh rabhadh le bhith ga thoirt air falbh bhon DOM. Ma tha na clasaichean .fade agus .show an làthair air an eileamaid, falbhaidh an rabhadh mus tèid a thoirt air falbh. |
$().alert('dispose') |
A 'sgrios rabhadh eileamaid. |
Bidh plugan rabhaidh Bootstrap a’ nochdadh grunn thachartasan airson a dhol a-steach do ghnìomhachd rabhaidh.
Tachartas | Tuairisgeul |
---|---|
close.bs.alert |
Bidh an tachartas seo a’ losgadh sa bhad nuair close a chanar ris an dòigh eisimpleir. |
closed.bs.alert |
Thèid an tachartas seo a losgadh nuair a tha an rabhadh dùinte (feitheamh ri eadar-ghluasadan CSS a chrìochnachadh). |