Likonopo
Sebelisa mekhoa ea tloaelo ea Bootstrap bakeng sa liketso ka mefuta, lipuisano, le tse ling ka tšehetso ea boholo bo fapaneng, linaha le tse ling.
Bootstrap e kenyelletsa mefuta e 'maloa ea likonopo e boletsoeng esale pele, e' ngoe le e 'ngoe e sebeletsa sepheo sa eona sa semantic, e nang le litlatsetso tse' maloa tse kentsoeng bakeng sa taolo e eketsehileng.
<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>
Ho fetisa moelelo ho litheknoloji tse thusang
Ho sebelisa mebala ho eketsa moelelo ho fana feela ka pontšo ea pono, e ke keng ea fetisetsoa ho basebelisi ba theknoloji e thusang - joalo ka sebali sa skrine. Netefatsa hore tlhahisoleseding e hlahisitsweng ke mmala e ka ba e totobetseng ho tswa ho dikahare ka boyona (mohlala, mongolo o bonahalang), kapa e kenyeleditswe ka mekgwa e meng, e kang mongolo o tlatsetso o patilweng le .sr-only
sehlopha.
Lihlopha .btn
li etselitsoe ho sebelisoa le <button>
element. Leha ho le joalo, u ka sebelisa litlelase tsena ho <a>
kapa <input>
likarolo (leha libatli tse ling li ka sebelisa phetolelo e fapaneng hanyane).
Ha o sebelisa li-button class ho <a>
likarolo tse sebelisetsoang ho qala ts'ebetso ea leqephe (joalo ka litaba tse putlamang), ho fapana le ho hokahana le maqephe a macha kapa likarolo tse ka har'a leqephe la hajoale, likhokahano tsena li lokela ho fuoa monyetla oa role="button"
ho fetisa sepheo sa tsona ka nepo ho mahlale a thusang joalo ka. babali ba skrine.
<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">
Na u hloka konopo, empa eseng mebala e meholo eo ba e tlisang? Beha sebaka sa litlelase tsa li-default ka .btn-outline-*
tse tla tlosa litšoantšo tsohle le mebala ho konopo efe kapa efe.
<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>
U batla likonopo tse kholoanyane kapa tse nyane? Eketsa .btn-lg
kapa .btn-sm
bakeng sa boholo bo eketsehileng.
<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>
Etsa likonopo tsa "block level" - tse fetang bophara ba motsoali - ka ho eketsa .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>
Likonopo li tla hlaha li hatisitsoe (ka bokamorao bo lefifi, moeli o motšo, le moriti o kenang) ha o sebetsa. Ha ho na tlhoko ea ho kenyelletsa sehlopha ho <button>
s ha ba ntse ba sebelisa sehlopha sa pseudo . Leha ho le joalo, o ntse o ka qobella ponahalo e ts'oanang e sebetsang ka .active
(mme o kenyelletsa aria-pressed="true"
semelo) haeba o hloka ho pheta naha ka mokhoa o hlophisitsoeng.
<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>
Etsa hore likonopo li shebahale li sa sebetse ka ho kenya disabled
tšobotsi ea boolean nthong efe kapa efe <button>
.
<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>
Likonopo tse holofetseng tse sebelisang <a>
element li sebetsa ka tsela e fapaneng:
<a>
s ha e tšehetsedisabled
tšobotsi, kahoo o tlameha ho eketsa.disabled
sehlopha ho etsa hore e bonahale e holofetse.- Mefuta e meng ea bokamoso e kenyellelitsoe ho tima tsohle
pointer-events
likonopong tsa ankora. Ho li-browser tse tšehetsang thepa eo, u ke ke ua bona sekhechana se holofetseng ho hang. - Likonopo tse holofetseng li tlameha ho kenyelletsa
aria-disabled="true"
tšobotsi ho bonts'a boemo ba element ho mahlale a thusang.
<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>
Khokahano ea ts'ebetso ea caveat
Sehlopha .disabled
se sebelisa pointer-events: none
ho leka ho tima ts'ebetso ea lihokelo tsa <a>
s, empa thepa eo ea CSS ha e so tloaelehe. Ho feta moo, esita le ho li-browser tse tšehetsang pointer-events: none
, ho tsamaea ha keyboard ho lula ho sa amehe, ho bolelang hore basebelisi ba li-keyboard ba boneng le basebelisi ba mahlale a thusang ba ntse ba tla khona ho kenya likhokahano tsena. E le hore u bolokehe, eketsa tabindex="-1"
tšobotsi ho lihokelo tsena (ho ba thibela ho fumana tsepamiso ea keyboard) 'me u sebelise JavaScript e tloaelehileng ho tima ts'ebetso ea bona.
Etsa ho eketsehileng ka likonopo. Konopo ea ho laola e bolela kapa theha lihlopha tsa likonopo bakeng sa likarolo tse ling tse kang lithulusi.
Eketsa data-toggle="button"
ho fetola boemo ba konopo active
. Haeba u toggle konopo pele, u tlameha ho kenya .active
sehlopha ka bowena le aria-pressed="true"
ho <button>
.
<button type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off">
Single toggle
</button>
Mekhoa ea Bootstrap e .button
ka sebelisoa ho likarolo tse ling, joalo ka <label>
s, ho fana ka lebokose la tlhahlobo kapa konopo ea setaele sa seea-le-moea. Eketsa data-toggle="buttons"
ho e .btn-group
nang le likonopo tse fetotsoeng ho thusa mokhoa oa bona oa ho fetola ka JavaScript le .btn-group-toggle
ho eketsa setaele sa <input>
s ka har'a likonopo tsa hau. Hlokomela hore o ka etsa likonopo tse nang le matla a le mong kapa lihlopha tsa tsona.
Boemo bo hlahlobiloeng ba likonopo tsena bo ntlafatsoa feela ka click
ketsahalo e konopo. Haeba u sebelisa mokhoa o mong oa ho nchafatsa lintho tseo u li kenyang—mohlala, ka <input type="reset">
ho sebelisa kapa ka ho sebelisa thepa eo u e kenyang checked
—u tla hloka ho sebelisa .active
mokhoa oo u o <label>
sebelisang.
Hlokomela hore likonopo tse hlahlobiloeng esale pele li hloka hore u kenye .active
sehlopha ka bowena ho tse kentsoeng <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>
Mokhoa | Tlhaloso |
---|---|
$().button('toggle') |
E fetola boemo ba push. E fa konopo ponahalo ea hore e kentsoe tšebetsong. |
$().button('dispose') |
E senya konopo ea element. |