Source

ceeb toom

Muab cov ntsiab lus tawm tswv yim tawm tswv yim rau cov neeg siv ib txwm ua nrog cov lus ceeb toom muaj thiab hloov pauv tau.

Piv txwv

Cov ntawv ceeb toom muaj nyob rau txhua qhov ntev ntawm cov ntawv nyeem, nrog rau qhov xaiv tso tseg khawm. Rau styling kom tsim nyog, siv ib qho ntawm yim yam uas yuav tsum tau muaj cov chav kawm (piv txwv li, .alert-success). Rau inline tshem tawm, siv cov lus ceeb toom jQuery plugin .

<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>
Qhia lub ntsiab lus rau kev pab technologies

Siv cov xim los ntxiv cov ntsiab lus tsuas yog muab qhov pom kev pom, uas yuav tsis raug xa mus rau cov neeg siv cov thev naus laus zis pab - xws li cov ntawv nyeem. Xyuas kom meej tias cov ntaub ntawv qhia los ntawm cov xim yog pom tseeb los ntawm cov ntsiab lus nws tus kheej (xws li cov ntawv pom), lossis suav nrog lwm txoj kev, xws li cov ntawv ntxiv zais nrog cov .sr-onlychav kawm.

Siv cov .alert-linkchav kawm siv hluav taws xob kom sai muab cov xim sib xws hauv ib qho kev ceeb toom.

<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>

Cov ntsiab lus ntxiv

Cov lus ceeb toom tuaj yeem muaj cov ntsiab lus HTML ntxiv xws li kab lus, kab lus thiab cov kab sib faib.

<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>

Tso tseg

Siv lub ceeb toom JavaScript plugin, nws muaj peev xwm tso tseg ib qho kev ceeb toom hauv kab. Nov yog li cas:

  • Nco ntsoov tias koj tau thauj khoom ceeb toom plugin, lossis suav nrog Bootstrap JavaScript.
  • Yog tias koj tab tom tsim peb JavaScript los ntawm qhov chaw, nws xav tauutil.js . Lub compiled version muaj xws li qhov no.
  • Ntxiv lub khawm tshem tawm thiab .alert-dismissiblechav kawm, uas ntxiv padding ntxiv rau sab xis ntawm kev ceeb toom thiab tso lub .closepob.
  • Ntawm lub pob tshem tawm, ntxiv tus data-dismiss="alert"cwj pwm, uas ua rau JavaScript ua haujlwm. Nco ntsoov siv lub <button>caij nrog nws rau kev coj tus cwj pwm zoo thoob plaws txhua yam khoom siv.
  • Txhawm rau ua kom muaj kev ceeb toom thaum tso tawm lawv, nco ntsoov ntxiv cov chav kawm .fadethiab .showcov chav kawm.

Koj tuaj yeem pom qhov no hauv kev nqis tes ua nrog qhov demo nyob:

<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">&times;</span>
  </button>
</div>

JavaScript cwj pwm

Ua rau

Pab kom tshem tawm kev ceeb toom ntawm JavaScript:

$('.alert').alert()

Los yog nrog cov datacwj pwm ntawm ib lub pob hauv qhov kev ceeb toom , raws li tau qhia saum toj no:

<button type="button" class="close" data-dismiss="alert" aria-label="Close">
  <span aria-hidden="true">&times;</span>
</button>

Nco ntsoov tias kaw qhov kev ceeb toom yuav tshem tawm ntawm DOM.

Cov txheej txheem

Txoj kev Kev piav qhia
$().alert() Ua kom ceeb toom mloog rau cov xwm txheej nyem ntawm cov xeeb leej xeeb ntxwv uas muaj tus data-dismiss="alert"cwj pwm. (Tsis tsim nyog thaum siv data-api's auto-initialization.)
$().alert('close') Kaw ib qho kev ceeb toom los ntawm kev tshem tawm ntawm DOM. Yog hais tias cov .fadethiab .showcov chav kawm muaj nyob rau ntawm lub caij, lub ceeb toom yuav ploj mus ua ntej nws yuav raug tshem tawm.
$().alert('dispose') Ua kom puas lub ntsiab lus ceeb toom.
$(".alert").alert('close')

Cov xwm txheej

Bootstrap's alert plugin nthuav tawm ob peb txheej xwm rau hooking rau hauv kev ceeb toom ua haujlwm.

Kev tshwm sim Kev piav qhia
close.bs.alert Qhov xwm txheej no tua hluav taws tam sim ntawd thaum closehu ua piv txwv.
closed.bs.alert Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub ceeb toom tau raug kaw (yuav tos rau CSS kev hloov pauv kom tiav).
$('#myAlert').on('closed.bs.alert', function () {
  // do something…
})