Source

Matohi

Whakaratohia nga karere urupare horopaki mo nga mahi a nga kaiwhakamahi me te ringaringa o nga karere matohi e waatea ana me te ngawari.

Tauira

Kei te waatea nga matohi mo te roanga o te kuputuhi, me te paatene whakakore. Kia tika te hanga, whakamahia tetahi o nga karaehe horopaki e waru e hiahiatia ana (hei tauira, .alert-success). Mo te whakakore i te raarangi, whakamahia te mono jQuery matohi .

<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>
Te kawe i te tikanga ki nga hangarau awhina

Ko te whakamahi i te tae ki te taapiri i te tikanga he tohu tirohanga noa iho, kaore e tukuna ki nga kaiwhakamahi hangarau awhina - penei i nga kaipanui mata. Me mohio kei te kitea nga korero e tohuhia ana e te tae mai i te ihirangi ake (hei tauira, te tuhinga ka kitea), ka whakaurua ranei ma etahi atu huarahi, penei i etahi atu tuhinga huna ki te .sr-onlyakomanga.

Whakamahia te .alert-linkkaraehe whaipainga ki te whakarato tere i nga hononga tae orite ki roto i tetahi matohi.

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

He ihirangi taapiri

Ka taea hoki e nga matohi etahi atu huānga HTML penei i nga pane, nga kowae me nga wehewehenga.

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

Te whakakore

Ma te whakamahi i te mono JavaScript matohi, ka taea te whakakore i nga raarangi matohi. Anei me pehea:

  • Kia mahara kua utaina e koe te mono mataara, te Bootstrap JavaScript ranei.
  • Mena kei te hanga koe i to maatau JavaScript mai i te puna, meutil.js . Kei roto i te putanga whakahiato tenei.
  • Tāpirihia he patene whakakore me te .alert-dismissiblekaraehe, he taapiri taapiri ki te taha matau o te matohi me te whakanoho i te .closepaatene.
  • I runga i te paatene whakakore, taapirihia te data-dismiss="alert"huanga, e whakaohooho ana i te mahi JavaScript. Me mohio ki te whakamahi i te <button>huānga me taua mea mo te whanonga tika puta noa i nga taputapu katoa.
  • Hei whakakorikori i nga matohi i te wa e whakakore ana i a raatau, me taapiri nga akomanga .fademe .shownga karaehe.

Ka taea e koe te kite i tenei mahi me te whakaaturanga ora:

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

Te whanonga JavaScript

Kaipupuri

Whakahohehia te whakakore i te matohi ma te JavaScript:

$('.alert').alert()

Me nga huanga ranei kei datarunga i te paatene i roto i te matohi , pera i te whakaaturanga i runga ake nei:

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

Kia mahara ko te kati i te matohi ka tangohia mai i te DOM.

Nga tikanga

Tikanga Whakaahuatanga
$().alert() He mataara ki te whakarongo ki nga takahanga pawhiri i runga i nga huānga uri kei a ia te data-dismiss="alert"huanga. (Kare e tika ina whakamahi i te arataki-aunoa a te raraunga-api.)
$().alert('close') Katia he matohi ma te tango mai i te DOM. Mena kei runga te .fademe .shownga karaehe i runga i te huānga, ka memeha haere te matohi i mua i te tangohanga.
$().alert('dispose') Ka whakakore i te matohi o tetahi huānga.
$(".alert").alert('close')

Nga huihuinga

Ko te mono matohi a Bootstrap e whakaatu ana i etahi huihuinga mo te hono ki te mahi mataara.

Takahanga Whakaahuatanga
close.bs.alert Ka pupuhi tenei takahanga ina ka closekarangahia te aratuka tauira.
closed.bs.alert Ka puhia tenei takahanga ina katia te matohi (ka tatari kia oti nga whakawhitinga CSS).
$('#myAlert').on('closed.bs.alert', function () {
  // do something…
})