Izilumkiso
Nikezela ngemiyalezo yengxelo yomxholo kwiintshukumo eziqhelekileyo zabasebenzisi kunye nesandla semiyalezo efumanekayo neguqukayo yesilumkiso.
Imizekelo
Izivuseleli ziyafumaneka kulo naliphi na ubude bombhalo, kunye neqhosha lokuchitha elikhethiweyo. Ukwenza isimbo esifanelekileyo, sebenzisa enye kwiiklasi ezisibhozo ezifunekayo.alert-success
(umz., ). Xa ugxothwa ngaphakathi, sebenzisa iplagi yezaziso zejQuery .
<div class="alert alert-primary" role="alert">
A simple primary alert—check it out!
</div>
<div class="alert alert-secondary" role="alert">
A simple secondary alert—check it out!
</div>
<div class="alert alert-success" role="alert">
A simple success alert—check it out!
</div>
<div class="alert alert-danger" role="alert">
A simple danger alert—check it out!
</div>
<div class="alert alert-warning" role="alert">
A simple warning alert—check it out!
</div>
<div class="alert alert-info" role="alert">
A simple info alert—check it out!
</div>
<div class="alert alert-light" role="alert">
A simple light alert—check it out!
</div>
<div class="alert alert-dark" role="alert">
A simple dark alert—check it out!
</div>
Ukuhambisa intsingiselo kwiiteknoloji ezincedisayo
Ukusebenzisa umbala ukongeza intsingiselo kubonelela kuphela ngesalathiso esibonakalayo, esingayi kuthunyelwa kubasebenzisi betekhnoloji encedisayo - njengezifundi zesikrini. Qinisekisa ukuba ulwazi olubonakaliswe ngumbala lucacile kumxholo ngokwawo (umzekelo, umbhalo obonakalayo), okanye luqukwe ngezinye iindlela, ezifana nesicatshulwa esongezelelweyo esifihlwe .sr-only
eklasini.
Umbala wekhonkco
Sebenzisa .alert-link
iklasi eluncedo ukubonelela ngokukhawuleza amakhonkco ahambelanayo anemibala ngaphakathi nasiphi na isivuseleli.
<div class="alert alert-primary" role="alert">
A simple 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">
A simple 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">
A simple 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">
A simple 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">
A simple 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">
A simple 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">
A simple 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">
A simple dark alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>
Umxholo owongezelelweyo
Izivuseleli zinokuqulatha izinto ezongezelelweyo zeHTML njengezihloko, imihlathi kunye nezahluli.
Wenze kakuhle!
Ewe, uwufunde ngempumelelo lo myalezo ubalulekileyo wesilumkiso. Lo mzekelo wokubhaliweyo uzakuqhuba ixesha elide ukuze ubone ukuba isithuba phakathi kwesivuseleli sisebenza njani ngolu hlobo lomxholo.
Nanini na xa ufuna, qiniseka ukuba usebenzisa izixhobo zomda ukugcina izinto zintle kwaye zicocekile.
<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>
Ukugxotha
Usebenzisa isivuseleli seplagi yeJavaScript, kuyenzeka ukuba ugxothe nasiphi na isivuseleli emgceni. Nantsi indlela:
- Qinisekisa ukuba ulayishile iplagi yesivuseleli, okanye i-JavaScript ye-Bootstrap ehlanganisiweyo.
- Ukuba wakha iJavaScript yethu kwimvelaphi, kufuna
util.js
. Inguqulelo ehlanganisiweyo ibandakanya oku. - Yongeza iqhosha lokugxotha kunye
.alert-dismissible
neklasi, eyongeza i-padding eyongezelelweyo ngasekunene kwesivuseleli kwaye ibeka.close
iqhosha. - Kwiqhosha lokugxotha, yongeza
data-dismiss="alert"
uphawu loyelelwano, oluqalisa ukusebenza kweJavaScript. Qinisekisa ukusebenzisa<button>
ielementi kunye nayo ngokuziphatha okufanelekileyo kuzo zonke izixhobo. - Ukuvuselela izilumkiso xa uzigxotha, qiniseka ukuba wongeza
.fade
kunye.show
neeklasi.
Ungayibona le nto isebenza ngedemo ephilayo:
<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>
Ukuziphatha kweJavaScript
Izichukumisi
Vula ukugxothwa kwesivuseleli ngeJavaScript:
$('.alert').alert()
Okanye ngeempawu data
kwiqhosha elingaphakathi kwesivuseleli , njengoko kubonisiwe ngasentla:
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
Qaphela ukuba ukuvala isilumkiso kuya kusisusa kwi-DOM.
Iindlela
Indlela | Inkcazo |
---|---|
$().alert() |
Yenza isivuseleli umamele ukwenzela unqakrazo lweziganeko kwizinto eziphumayo data-dismiss="alert" ezinophawu. (Akuyomfuneko xa usebenzisa idatha-api's auto-initialization.) |
$().alert('close') |
Ivala isilumkiso ngokusisusa kwiDOM. Ukuba i .fade kunye .show neeklasi zikhona kwinto, isivuseleli siya kuphelelwa phambi kokuba sisuswe. |
$().alert('dispose') |
Itshabalalisa isilumkiso sento. |
$('.alert').alert('close')
Iziganeko
Iplagi yesilumkiso ye-Bootstrap iveza iminyhadala embalwa yokuqhagamshelwa kusetyenziso lwesilumkiso.
Isiganeko | Inkcazo |
---|---|
close.bs.alert |
Esi siganeko sivutha ngokukhawuleza xa close kubizwa indlela yomzekelo. |
closed.bs.alert |
Esi siganeko sigxothwa xa isivuseleli sivaliwe (siya kulinda iinguqu zeCSS ukuba zigqitywe). |
$('#myAlert').on('closed.bs.alert', function () {
// do something...
})