Mabatani
Gwiritsani ntchito masitayilo a Bootstrap pamabatani kuti muchitepo kanthu m'mitundu, zokambirana, ndi zina zambiri mothandizidwa ndi makulidwe angapo, zigawo, ndi zina zambiri.
Bootstrap imaphatikizapo masitayelo angapo ofotokozedweratu, iliyonse imagwira ntchito yakeyake, ndi zina zowonjezera zomwe zimaponyedwa kuti ziziwongolera.
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-secondary">Secondary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-light">Light</button>
<button type="button" class="btn btn-dark">Dark</button>
<button type="button" class="btn btn-link">Link</button>
Kupereka tanthauzo ku matekinoloje othandizira
Kugwiritsa ntchito utoto kuti muwonjezere tanthauzo kumangopereka chithunzithunzi, chomwe sichidzaperekedwa kwa ogwiritsa ntchito matekinoloje othandizira - monga owerenga pazenera. Onetsetsani kuti zomwe zatchulidwa ndi mtunduwo zikuwonekera kuchokera pazomwe zili (monga zolemba zowonekera), kapena zikuphatikizidwa ndi njira zina, monga zolemba zina zobisika ndi .sr-only
kalasi.
Maphunzirowa .btn
amapangidwa kuti agwiritsidwe ntchito ndi <button>
element. Komabe, mutha kugwiritsanso ntchito makalasi awa <a>
kapena <input>
zinthu (ngakhale asakatuli ena atha kugwiritsa ntchito kumasulira kosiyana pang'ono).
Mukamagwiritsa ntchito mabatani azinthu <a>
zomwe zimagwiritsidwa ntchito kuyambitsa ntchito zapatsamba (monga kugwa), m'malo molumikizana ndi masamba atsopano kapena magawo omwe ali patsamba lapano, maulalo awa ayenera kuperekedwa role="button"
kuti afotokozere moyenera cholinga chawo kuukadaulo wothandizira monga. owerenga chophimba.
<a class="btn btn-primary" href="#" role="button">Link</a>
<button class="btn btn-primary" type="submit">Button</button>
<input class="btn btn-primary" type="button" value="Input">
<input class="btn btn-primary" type="submit" value="Submit">
<input class="btn btn-primary" type="reset" value="Reset">
Mukufuna batani, koma osati mitundu yayikulu yakumbuyo yomwe amabweretsa? Bwezerani m'malo mwa makalasi osintha .btn-outline-*
kuti muchotse zithunzi zonse zakumbuyo ndi mitundu pa batani lililonse.
<button type="button" class="btn btn-outline-primary">Primary</button>
<button type="button" class="btn btn-outline-secondary">Secondary</button>
<button type="button" class="btn btn-outline-success">Success</button>
<button type="button" class="btn btn-outline-danger">Danger</button>
<button type="button" class="btn btn-outline-warning">Warning</button>
<button type="button" class="btn btn-outline-info">Info</button>
<button type="button" class="btn btn-outline-light">Light</button>
<button type="button" class="btn btn-outline-dark">Dark</button>
Mukufuna mabatani akulu kapena ang'onoang'ono? Onjezani .btn-lg
kapena .btn-sm
ma size owonjezera.
<button type="button" class="btn btn-primary btn-lg">Large button</button>
<button type="button" class="btn btn-secondary btn-lg">Large button</button>
<button type="button" class="btn btn-primary btn-sm">Small button</button>
<button type="button" class="btn btn-secondary btn-sm">Small button</button>
Pangani mabatani a block level—omwe amatambasula m'lifupi mwa kholo lonse—powonjezera .btn-block
.
<button type="button" class="btn btn-primary btn-lg btn-block">Block level button</button>
<button type="button" class="btn btn-secondary btn-lg btn-block">Block level button</button>
Mabatani adzawoneka atapanikizidwa (ndi maziko akuda, malire akuda, ndi mthunzi wamkati) akamagwira ntchito. Palibe chifukwa chowonjezera kalasi ku <button>
s pomwe amagwiritsa ntchito kalasi yabodza . Komabe, mutha kukakamizabe mawonekedwe omwewo .active
(ndikuphatikizanso aria-pressed="true"
) ngati mungafunikire kubwereza boma mwadongosolo.
<a href="#" class="btn btn-primary btn-lg active" role="button" aria-pressed="true">Primary link</a>
<a href="#" class="btn btn-secondary btn-lg active" role="button" aria-pressed="true">Link</a>
Pangani mabatani kuti awoneke ngati osagwira ntchito powonjezera mawonekedwe a disabled
boolean ku <button>
chinthu chilichonse.
<button type="button" class="btn btn-lg btn-primary" disabled>Primary button</button>
<button type="button" class="btn btn-secondary btn-lg" disabled>Button</button>
Mabatani olemala omwe amagwiritsa ntchito <a>
chinthucho amachita mosiyana pang'ono:
<a>
s sizigwirizana ndidisabled
chikhalidwecho, chifukwa chake muyenera kuwonjezera.disabled
kalasi kuti iwoneke ngati yolumala.- Masitayelo ena ogwirizana ndi mtsogolo akuphatikizidwa kuti muyimitse zonse pamabatani
pointer-events
a nangula. M'masakatuli omwe amathandizira katunduyo, simudzawona cholozera choyimitsidwa konse. - Mabatani olemala akuyenera kukhala ndi mawonekedwe
aria-disabled="true"
owonetsa momwe zinthu zilili kuukadaulo wothandizira.
<a href="#" class="btn btn-primary btn-lg disabled" role="button" aria-disabled="true">Primary link</a>
<a href="#" class="btn btn-secondary btn-lg disabled" role="button" aria-disabled="true">Link</a>
Link magwiridwe antchito chenjezo
Kalasiyo .disabled
imagwiritsa ntchito pointer-events: none
kuyesa kuletsa magwiridwe antchito a <a>
s, koma katundu wa CSS sunakhazikitsidwebe. Kuphatikiza apo, ngakhale m'masakatuli omwe amathandizira pointer-events: none
, kuyenda kwa kiyibodi sikukhudzidwa, kutanthauza kuti ogwiritsa ntchito kiyibodi omwe amawona komanso ogwiritsa ntchito matekinoloje othandizira azitha kuyatsa maulalo awa. Chifukwa chake kuti mukhale otetezeka, onjezani zomwe tabindex="-1"
zili pamalumikizidwe awa (kuti muwaletse kuti asalandire chidwi cha kiyibodi) ndikugwiritsa ntchito JavaScript kuti mulepheretse magwiridwe ake.
Chitani zambiri ndi mabatani. Batani lowongolera likunena kapena pangani magulu a mabatani azinthu zambiri ngati zida.
Onjezani data-toggle="button"
kuti musinthe mawonekedwe a batani active
. Ngati musinthiratu batani, muyenera kuwonjezera pamanja .active
kalasi ndi aria-pressed="true"
ku <button>
.
<button type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off">
Single toggle
</button>
Masitayilo a Bootstrap .button
atha kugwiritsidwa ntchito pazinthu zina, monga <label>
s, kuti apereke bokosi loyang'ana kapena mabatani a wayilesi. Onjezani data-toggle="buttons"
ku .btn-group
zomwe zili ndi mabatani osinthidwawo kuti athe kusintha machitidwe awo kudzera pa JavaScript ndikuwonjezera .btn-group-toggle
masitayilo omwe <input>
ali mkati mwa mabatani anu. Zindikirani kuti mutha kupanga mabatani olowetsa mphamvu imodzi kapena magulu awo.
Mawonekedwe osankhidwa a mabataniwa amangosinthidwa ndi chochitika click
chomwe chili pa batani. Ngati mugwiritsa ntchito njira ina yosinthira zomwe mwalowetsamo, mwachitsanzo, pogwiritsa <input type="reset">
ntchito kapena kugwiritsa ntchito pamanja zomwe checked
mwalowetsamo, muyenera kusintha .active
pamanja <label>
.
Zindikirani kuti mabatani omwe adasankhidwa kale amafuna kuti muwonjezere .active
kalasi pa zolowetsa <label>
.
<div class="btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary active">
<input type="checkbox" checked autocomplete="off"> Checked
</label>
</div>
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary active">
<input type="radio" name="options" id="option1" autocomplete="off" checked> Active
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="option2" autocomplete="off"> Radio
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="option3" autocomplete="off"> Radio
</label>
</div>
Njira | Kufotokozera |
---|---|
$().button('toggle') |
Imatembenuza dziko lokankhira. Imawonetsa batani kuwonekera kuti yayatsidwa. |
$().button('dispose') |
Iwononga batani la chinthu. |