Izilumkiso
Nikezela ngemiyalezo yengxelo yomxholo kwiintshukumo eziqhelekileyo zabasebenzisi kunye nesandla semiyalezo efumanekayo neguqukayo yesilumkiso.
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">
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>
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.
Sebenzisa .alert-link
iklasi eluncedo ukubonelela ngokukhawuleza amakhonkco ahambelanayo anemibala ngaphakathi nasiphi na isivuseleli.
<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>
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>
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>
Vula ukugxothwa kwesivuseleli ngeJavaScript:
Okanye ngeempawu data
kwiqhosha elingaphakathi kwesivuseleli , njengoko kubonisiwe ngasentla:
Qaphela ukuba ukuvala isilumkiso kuya kusisusa kwi-DOM.
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. |
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). |