Source

Imenyesha

Tanga ibitekerezo byubutumwa bwibikorwa kubikorwa bisanzwe byabakoresha hamwe nubutumwa buboneka kandi bworoshye bwo kumenyesha.

Ingero

Imenyesha riraboneka kuburebure bwinyandiko, kimwe nubushake bwo kwirukana. Kuburyo bukwiye, koresha kimwe mubyiciro umunani bisabwa.alert-success (urugero, ). Kubirukana kumurongo, koresha imenyesha 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>
Gutanga ibisobanuro kubuhanga bufasha

Gukoresha ibara kugirango wongere ibisobanuro bitanga gusa icyerekezo cyerekana, kitazashyikirizwa abakoresha tekinoroji ifasha - nk'abasoma ecran. Menya neza ko amakuru yerekanwe n'ibara agaragara uhereye kubirimo ubwabyo (urugero: inyandiko igaragara), cyangwa bigashyirwa muburyo butandukanye, nk'inyandiko y'inyongera ihishe hamwe .sr-onlyn'ishuri.

Koresha urwego .alert-linkrwingirakamaro kugirango utange byihuse guhuza amabara muburyo ubwo aribwo bwose.

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

Ibirimo

Imenyesha rishobora kandi kubamo HTML yinyongera nkimitwe, paragarafu nabatandukanya.

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

Kwirukana

Ukoresheje plugin ya JavaScript imenyesha, birashoboka gusezerera umurongo uwo ari wo wose. Dore uko:

  • Menya neza ko wapakiye plugin yo kumenyesha, cyangwa icyegeranyo cya Bootstrap JavaScript.
  • Niba wubaka JavaScript yacu kuva isoko, birasabautil.js . Inyandiko yakozwe ikubiyemo ibi.
  • Ongeraho buto yo kwirukana hamwe .alert-dismissiblenishuri, byongeramo padi iburyo bwiburyo bwo kumenyesha no gushyira .closebuto.
  • Kuri buto yo kwirukana, ongeramo data-dismiss="alert"ikiranga, gikurura imikorere ya JavaScript. Witondere gukoresha <button>element hamwe nayo kugirango imyitwarire iboneye mubikoresho byose.
  • Kugirango ushushanye kumenyesha mugihe ubirukanye, menya kongeramo .fadeamasomo .show.

Urashobora kubibona mubikorwa hamwe na demo nzima:

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

Imyitwarire ya JavaScript

Imbarutso

Emera kwirukana integuza ukoresheje JavaScript:

$('.alert').alert()

Cyangwa hamwe datanibiranga kuri buto mubimenyeshejwe , nkuko byerekanwe hejuru:

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

Menya ko gufunga integuza bizayikuraho muri DOM.

Uburyo

Uburyo Ibisobanuro
$().alert() Kora integuza yumve gukanda ibyabaye kubintu bikomokaho bifite data-dismiss="alert"ikiranga. (Ntabwo ari ngombwa mugihe ukoresheje data-api yo gutangiza-auto.)
$().alert('close') Funga integuza uyikuye muri DOM. Niba i .fadehamwe .shownamasomo ahari kuri element, integuza izashira mbere yuko ikurwaho.
$().alert('dispose') Gusenya ikintu cyo kumenyesha.
$(".alert").alert('close')

Ibyabaye

Amacomeka ya Bootstrap yerekana ibintu bike byo guhuza ibikorwa.

Icyabaye Ibisobanuro
close.bs.alert Ibirori birasa ako kanya mugihe closeurugero rwitwa.
closed.bs.alert Ibi birori birukanwa mugihe integuza yafunzwe (izategereza ko CSS ihinduka).
$('#myAlert').on('closed.bs.alert', function () {
  // do something…
})