Mu awọn paati Bootstrap wa si igbesi aye — ni bayi pẹlu aṣa jQuery aṣa 13.
Awọn afikun le wa pẹlu ẹyọkan (botilẹjẹpe diẹ ninu awọn ti nilo awọn igbẹkẹle), tabi gbogbo ni ẹẹkan. Awọn mejeeji bootstrap.js ati bootstrap.min.js ni gbogbo awọn afikun ninu faili kan.
O le lo gbogbo awọn afikun Bootstrap nikan nipasẹ API isamisi laisi kikọ laini kan ti JavaScript. Eyi jẹ API kilasi akọkọ Bootstrap ati pe o yẹ ki o jẹ akiyesi akọkọ rẹ nigbati o nlo ohun itanna kan.
Iyẹn ti sọ, ni awọn ipo miiran o le jẹ iwunilori lati pa iṣẹ ṣiṣe yii. Nitoribẹẹ, a tun pese agbara lati mu awọn abuda data API kuro nipa yiyọ gbogbo awọn iṣẹlẹ lori orukọ ara ti o ni aaye pẹlu `'data-api'`. Eyi dabi eyi:
- $ ( 'ara' ). pipa ( '.data-api' )
Ni omiiran, lati fojusi ohun itanna kan pato, kan ṣafikun orukọ ohun itanna bi aaye orukọ kan pẹlu aaye orukọ data-api bii eyi:
- $ ( 'ara' ). pipa ( '.alert.data-api' )
A tun gbagbọ pe o yẹ ki o ni anfani lati lo gbogbo awọn afikun Bootstrap nikan nipasẹ JavaScript API. Gbogbo API ti gbogbo eniyan jẹ ẹyọkan, awọn ọna ẹwọn, ati da ikojọpọ ti a ṣiṣẹ lori pada.
- $ ( ".btn.danger" ). bọtini ( "bayi" ). addClass ( "ọra" )
Gbogbo awọn ọna yẹ ki o gba ohun aṣayan aṣayan, okun ti o fojusi ọna kan pato, tabi ohunkohun (eyiti o bẹrẹ ohun itanna kan pẹlu ihuwasi aiyipada):
- $ ( "#myModal" ). modal () // ipilẹṣẹ pẹlu awọn aiyipada
- $ ( "#myModal" ). modal ({ bọọdù : irọ }) // ti a ṣe ipilẹṣẹ lai si keyboard
- $ ( "#myModal" ). modal ( 'fihan' ) // awọn ipilẹṣẹ ati awọn invokes fihan lẹsẹkẹsẹ
Ohun itanna kọọkan tun ṣe afihan olupilẹṣẹ aise rẹ lori ohun-ini `Constructor` $.fn.popover.Constructor
:. Ti o ba fẹ lati gba apẹẹrẹ itanna kan pato, gba pada taara lati ẹya: $('[rel=popover]').data('popover')
.
Nigba miiran o jẹ dandan lati lo awọn afikun Bootstrap pẹlu awọn ilana UI miiran. Ni awọn ipo wọnyi, awọn ikọlu aaye orukọ le waye lẹẹkọọkan. Ti eyi ba ṣẹlẹ, o le pe .noConflict
ohun itanna ti o fẹ lati yi iye pada.
- var bootstrapButton = $ . fn . bọtini . noConflict () // pada $.fn.bọtini si iye ti a yàn tẹlẹ
- $ . fn . bootstrapBtn = bootstrapButton // fun $ () .bootstrapBtn iṣẹ-ṣiṣe bootstrap
Bootstrap n pese awọn iṣẹlẹ aṣa fun ọpọlọpọ awọn iṣe alailẹgbẹ ohun itanna. Ni gbogbogbo, iwọnyi wa ni fọọmu ailopin ati ti o ti kọja - nibiti ailopin (fun apẹẹrẹ show
) ti jẹ okunfa ni ibẹrẹ iṣẹlẹ, ati fọọmu apakan ti o kọja (fun apẹẹrẹ shown
) jẹ okunfa lori ipari iṣẹ kan.
Gbogbo awọn iṣẹlẹ ailopin pese idilọwọ iṣẹ ṣiṣe Aiyipada. Eyi n pese agbara lati da ipaniyan ti iṣe ṣaaju ki o to bẹrẹ.
- $ ( '#myModal' ). lori ( 'fihan' , iṣẹ ( e ) {
- ti (! data ) pada e . idilọwọDefault () // da modal duro lati han
- })
Fun awọn ipa iyipada ti o rọrun, pẹlu bootstrap-transition.js lẹẹkan lẹgbẹẹ awọn faili JS miiran. Ti o ba nlo bootstrap.js ti o ṣajọpọ (tabi miniified) , ko si ye lati ṣafikun eyi — o ti wa tẹlẹ.
Awọn apẹẹrẹ diẹ ti ohun itanna iyipada:
Modals ti wa ni ṣiṣan, ṣugbọn rọ, awọn itọsi ọrọ sisọ pẹlu iṣẹ ṣiṣe ti o kere julọ ti a beere ati awọn aṣiṣe ọlọgbọn.
Modal ti a ṣe pẹlu akọsori, ara, ati ṣeto awọn iṣe ni ẹlẹsẹ.
Ara kan ti o dara…
- <div class = "modal hide ipare" >
- <div kilasi = "modal-akọsori" >
- <bọtini iru = "bọtini" kilasi = "sunmọ" data-dismiss = "modal" aria-hidden = "otitọ" > × </bọtini>
- <h3> Akọsori awoṣe </h3>
- </div>
- <div class = "modal-body" >
- <p> Ara kan ti o dara… </p>
- </div>
- <div class = "modal-footer" >
- <a href = "#" kilasi = "btn"> Pade </a> _
- <a href = "#" kilasi = "btn btn-primary" > Fipamọ awọn ayipada </a>
- </div>
- </div>
Yi modal pada nipasẹ JavaScript nipa titẹ bọtini ni isalẹ. Yoo rọra si isalẹ ati ipare ni lati oke ti oju-iwe naa.
- <!-- Bọtini lati ṣe okunfa modal -->
- <a href = "#myModal" ipa = "bọtini" kilasi = "btn" data-toggle = "modal" > Ifilọlẹ demo modal </a>
- <!-- Modal -->
- <div id = "myModal" kilasi = "modal hide fade" tabindex = "-1" ipa = "dialog" aria-labelledby = "myModalLabel" aria-hidden = "otitọ" >
- <div kilasi = "modal-akọsori" >
- <button type = "bọtini" kilasi = "sunmọ" data-dismiss = "modal" aria-hidden = "otitọ" > × </button>
- <h3 id = "myModalLabel" > Akọsori awoṣe </h3>
- </div>
- <div class = "modal-body" >
- <p> Ara kan ti o dara… </p>
- </div>
- <div class = "modal-footer" >
- <button class = "btn" data-dismiss = "modal" aria-hidden = "otitọ" > Pade </button>
- <bọtini kilasi = "btn btn-primary" > Fipamọ awọn ayipada </button>
- </div>
- </div>
Mu modal ṣiṣẹ laisi kikọ JavaScript. Ṣeto data-toggle="modal"
lori eroja oludari, bii bọtini kan, pẹlu kan data-target="#foo"
tabi href="#foo"
lati fojusi modal kan pato lati yi.
- <button type = "bọtini" data-toggle = "modal" data-target = "#myModal" > Modal ifilọlẹ </button>
Pe modal pẹlu id myModal
pẹlu laini JavaScript kan:
- $ ( '#myModal' ). modal ( awọn aṣayan )
Awọn aṣayan le ṣee kọja nipasẹ awọn abuda data tabi JavaScript. Fun awọn abuda data, fi orukọ aṣayan si data-
, bi ninu data-backdrop=""
.
Oruko | iru | aiyipada | apejuwe |
---|---|---|---|
sile | boolian | ooto | Pẹlu a modal-backdrop ano. Ni omiiran, pato static fun ẹhin ẹhin eyiti ko pa modal naa ni titẹ. |
keyboard | boolian | ooto | Tilekun modal nigbati o ba tẹ bọtini ona abayo |
ifihan | boolian | ooto | Ṣe afihan modal nigbati o bẹrẹ. |
latọna jijin | ona | eke | Ti o ba pese url latọna jijin, akoonu yoo jẹ kojọpọ nipasẹ ọna jQuery
|
Mu akoonu rẹ ṣiṣẹ bi modal. Gba awọn aṣayan iyan object
.
- $ ( '#myModal' ). modal ({
- keyboard : iro
- })
Pẹlu ọwọ yipada modal kan.
- $ ( '#myModal' ). modal ( 'yii' )
Pẹlu ọwọ ṣii modal kan.
- $ ( '#myModal' ). modal ( 'ifihan' )
Pẹlu ọwọ hides a modal.
- $ ( '#myModal' ). modal ( 'tọju' )
Kilasi modal Bootstrap ṣafihan awọn iṣẹlẹ diẹ fun sisọ sinu iṣẹ ṣiṣe modal.
Iṣẹlẹ | Apejuwe |
---|---|
ifihan | Yi iṣẹlẹ ina lẹsẹkẹsẹ nigbati awọn show apẹẹrẹ ọna ti a npe ni. |
han | Iṣẹlẹ yii jẹ ina nigbati modal ti jẹ ki o han si olumulo (yoo duro fun awọn iyipada css lati pari). |
tọju | Iṣẹlẹ yii jẹ ina lẹsẹkẹsẹ nigbati ọna hide apẹẹrẹ ti pe. |
farasin | Iṣẹlẹ yii jẹ ina nigbati modal naa ba ti pari fifipamọ lati ọdọ olumulo (yoo duro fun awọn iyipada css lati pari). |
- $ ( '#myModal' ). lori ( 'farasin' , iṣẹ () {
- // se nkan…
- })
Ṣafikun awọn akojọ aṣayan silẹ si ohunkohun pẹlu ohun itanna ti o rọrun yii, pẹlu navbar, awọn taabu, ati awọn oogun.
Ṣafikun data-toggle="dropdown"
si ọna asopọ kan tabi bọtini lati yi jisilẹ silẹ.
- <div kilasi = "silẹ silẹ" >
- <a class = "dropdown-toggle" data-toggle = "dropdown" href = "#" > Ohun okunfa sisọ silẹ </a>
- <ul class = "menu dropdown" ipa = "akojọ-akojọ" aria-labelledby = "dLabel" >
- ...
- </ul>
- </div>
Lati jẹ ki awọn URL wa titi, lo data-target
abuda dipo href="#"
.
- <div kilasi = "silẹ silẹ" >
- <a class = "dropdown-toggle" id = "dLabel" ipa = "bọtini" data-toggle = " dropdown" data-target = "#" href = "/page.html" >
- Faa silẹ
- <b kilasi = "abojuto" </b>
- </a>
- <ul class = "menu dropdown" ipa = "akojọ-akojọ" aria-labelledby = "dLabel" >
- ...
- </ul>
- </div>
Pe awọn silẹ nipasẹ JavaScript:
- $ ( '.dropdown-toggle' ). silẹ ()
Ko si
Api eto kan fun awọn akojọ aṣayan yipo fun navbar ti a fun tabi lilọ kiri taabu.
Ohun itanna ScrollSpy jẹ fun mimu dojuiwọn awọn ibi-afẹde nav da lori ipo yi lọ. Yi lọ si agbegbe ni isalẹ navbar ki o wo iyipada kilasi ti nṣiṣe lọwọ. Awọn nkan isọ silẹ yoo jẹ afihan bi daradara.
Ad leggings keytar, brunch id art party dolor labour. Pitchfork yr enim lo-fi kí wọn tó ta qui. Tumblr oko-to-tabili awọn ẹtọ keke ohunkohun ti. Animu keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby siweta lomo Jean shorts, Williamsburg hoodie minim qui o jasi ko ti gbọ ti wọn et cardigan Trust fund culpa biodiesel wes anderson aesthetic. Nihi tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork irungbọn. Freegan irungbọn aliqua cupidatat mcsweeney ká vero. Cupidatat mẹrin loko nisi, ea helvetica nulla carles. Tatuu cosby siweta ounje ikoledanu, mcsweeney ká quis ti kii freegan fainali. Lo-fi wes anderson +1 sartorial. Carles ti kii ṣe adaṣe darapupo quis gentrify. Brooklyn adipisicing ọnà ọti igbakeji keytar deserunt.
Occaecat commodo aliqua delectus. Fap iṣẹ ọti deserunt skateboard ea. Lomo keke awọn ẹtọ adipisicing banh mi, velit ea sunt next level locavore nikan-origin kofi in magna veniam. Igbesi aye giga id fainali, iwoyi o duro si ibikan consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing. Consectetur nisi DIY minim ojiṣẹ apo. cred ex in, alagbero delectus consectetur fanny pack ipad.
In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.
Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
Keytar twee bulọọgi, culpa ojiṣẹ apo marfa ohunkohun ti delectus ounje ikoledanu. Sapiente synth id assumenda. Locavore sed helvetica cliche irony, thundercats o jasi ko tii gbọ ti wọn consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat ṣaaju ki wọn to ta, Terry Richardson proident brunch nesciunt quis cosby siweta pariatur keffiyeh ut helvetica artisan. Cardigan iṣẹ ọti seitan readymade velit. VHS chambray laboris tempor veniam. Animu mollit minim commodo ullamco thundercats.
Lati fi awọn iṣọrọ scrollspy ihuwasi si rẹ topbar lilọ, o kan fi data-spy="scroll"
si awọn ano ti o fẹ lati ṣe amí lori (julọ ojo melo yi yoo jẹ ara) ati data-target=".navbar"
lati yan eyi ti nav lati lo. Iwọ yoo fẹ lati lo scrollspy pẹlu .nav
paati kan.
- <body data-spy = "yi lọ" data-target = ".navbar" > ... </body>
Pe scrollspy nipasẹ JavaScript:
- $ ( '#navbar' ). scrollspy ()
<a href="#home">home</a>
gbọdọ ba nkan ṣe ni dom bi
<div id="home"></div>
.
Nigbati o ba nlo scrollspy ni apapo pẹlu fifi kun tabi yiyọ awọn eroja kuro lati DOM, iwọ yoo nilo lati pe ọna isọdọtun bii bẹ:
- $ ( '[data-spy="yilọ" ). kọọkan ( iṣẹ () {
- var $ amí = $ ( eyi ). scrollspy ( 'itura' )
- });
Awọn aṣayan le ṣee kọja nipasẹ awọn abuda data tabi JavaScript. Fun awọn abuda data, fi orukọ aṣayan si data-
, bi ninu data-offset=""
.
Oruko | iru | aiyipada | apejuwe |
---|---|---|---|
aiṣedeede | nọmba | 10 | Awọn piksẹli lati aiṣedeede lati oke nigbati o ṣe iṣiro ipo ti yi lọ. |
Iṣẹlẹ | Apejuwe |
---|---|
mu ṣiṣẹ | Iṣẹlẹ yii n ṣiṣẹ nigbakugba ti ohun kan ba muu ṣiṣẹ nipasẹ scrollspy. |
Ṣafikun iyara, iṣẹ ṣiṣe taabu ti o ni agbara si iyipada nipasẹ awọn pane ti akoonu agbegbe, paapaa nipasẹ awọn akojọ aṣayan silẹ.
Aise Denimu o jasi ko ti gbọ ti wọn Jean shorts Austin. Nesciunt tofu stumptown aliqua, Retiro synth titunto si wẹ. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum ipad. Seitan aliquip quis cardigan American aso, butcher voluptate nisi qui.
Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.
Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.
Trust fund seitan letterpress, keytar raw Denim keffiyeh etsy art party ki wọn to ta oluwa wẹ giluteni-free squid scenester freegan cosby siweta. Fanny pack portland seitan DIY, art party locavore Ikooko cliche ga aye iwoyi o duro si ibikan Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi ṣaaju ki wọn to ta oko-si-tabili VHS gbogun ti locavore cosby siweta. Lomo wolf viral, mustache readymade thundercats keffiyeh craft ọti marfa ethical. Wolf salvia freegan, sartorial keffiyeh iwoyi o duro si ibikan ajewebe.
Mu awọn taabu taabu ṣiṣẹ nipasẹ JavaScript (taabu kọọkan nilo lati muu ṣiṣẹ ni ẹyọkan):
- $ ( '#myTab a' ). tẹ ( iṣẹ ( e ) {
- e . idilọwọ Aiyipada ();
- $ ( eyi ). taabu ( 'ifihan' );
- })
O le mu awọn taabu kọọkan ṣiṣẹ ni awọn ọna pupọ:
- $ ( '#myTab a[href="#profaili"]' ). taabu ( 'ifihan' ); // Yan taabu nipa orukọ
- $ ( '#myTab a: akọkọ' ). taabu ( 'ifihan' ); // Yan taabu akọkọ
- $ ( '#myTab a: kẹhin' ). taabu ( 'ifihan' ); // Yan kẹhin taabu
- $ ( '#myTab li: eq(2) a' ). taabu ( 'ifihan' ); // Yan taabu kẹta (0-itọkasi)
O le mu taabu kan ṣiṣẹ tabi lilọ kiri egbogi laisi kikọ eyikeyi JavaScript nipa sisọ pato data-toggle="tab"
tabi data-toggle="pill"
lori nkan kan. Ṣafikun nav
ati nav-tabs
awọn kilasi si taabu ul
yoo lo iselona taabu Bootstrap.
- <ul kilasi = "nav nav-tabs" >
- <li><a href = "#home" data-toggle = "taabu" > Ile </a></li>
- <li><a href = "#profile" data-toggle = "taabu" > Profaili </a></li>
- <li><a href = "#messages" data-toggle = "taabu" > Awọn ifiranṣẹ </a></li>
- <li><a href = "#settings" data-toggle = "taabu" > Eto </a></li>
- </ul>
Mu eroja taabu ṣiṣẹ ati eiyan akoonu. Taabu yẹ ki o ni boya a data-target
tabi href
ifọkansi oju ipade apoti kan ninu DOM.
- <ul kilasi = "nav nav-tabs" id = "myTab" >
- <li class = "lọwọ" ><a href = "#ile" > Ile </a></li>
- <li > <a href = "#profaili"> Profaili </a></li>
- <li><a href = "#messages" > Awọn ifiranṣẹ </a></li>
- <li><a href = "#eto" > Eto </a></li>
- </ul>
- <div class = "akoonu-taabu" >
- <div class = "tab-pane active" id = "ile" > ... </div>
- <div class = "tab-pane" id = "profaili" > ... </div>
- <div class = "tab-pane" id = "awọn ifiranṣẹ" > ... </div>
- <div class = "tab-pane" id = "awọn eto" > ... </div>
- </div>
- <akosile>
- $ ( iṣẹ () {
- $ ( '#myTab a: kẹhin' ). taabu ( 'ifihan' );
- })
- </script>
Iṣẹlẹ | Apejuwe |
---|---|
ifihan | Iṣẹlẹ yii ina lori ifihan taabu, ṣugbọn ṣaaju ki o to han taabu tuntun. Lo event.target ati event.relatedTarget lati fojusi taabu ti nṣiṣe lọwọ ati taabu lọwọlọwọ ti tẹlẹ (ti o ba wa) lẹsẹsẹ. |
han | Iṣẹlẹ yi ina lori ifihan taabu lẹhin ti a ti fi taabu kan han. Lo event.target ati event.relatedTarget lati fojusi taabu ti nṣiṣe lọwọ ati taabu lọwọlọwọ ti tẹlẹ (ti o ba wa) lẹsẹsẹ. |
- $ ( 'a[data-toggle = "taabu"]' ). lori ( 'fi han' , iṣẹ ( e ) {
- e . afojusun // mu ṣiṣẹ taabu
- e . jẹmọTarget // ti tẹlẹ taabu
- })
Atilẹyin nipasẹ ohun itanna jQuery.tipsy ti o dara julọ ti a kọ nipasẹ Jason Frame; Awọn imọran irinṣẹ jẹ ẹya imudojuiwọn, eyiti ko gbẹkẹle awọn aworan, lo CSS3 fun awọn ohun idanilaraya, ati awọn abuda data fun ibi ipamọ akọle agbegbe.
Fun awọn idi iṣẹ ṣiṣe, ohun elo irinṣẹ ati popover data-apis ti wọle, afipamo pe o gbọdọ ṣe ipilẹṣẹ wọn funrararẹ .
Raba lori awọn ọna asopọ ni isalẹ lati wo awọn imọran irinṣẹ:
Awọn sokoto to gun ni ipele keji keffiyeh o ṣee ṣe ko tii gbọ ti wọn. Photo agọ irungbọn aise Denimu letterpress ajewebe ojiṣẹ apo stumptown. Farm-to-tabili seitan, mcsweeney's fixie alagbero quinoa 8-bit American aṣọ ni Terry Richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, mẹrin loko mcsweeney ká cleanse vegan chambray. A gan ironic artisan whatever keytar , scenester farm-to-table banksy Austin twitter handle freegan cred raw Denimu nikan-Oti kofi gbogun ti.
Nigbati o ba nlo awọn itọsi irinṣẹ ati awọn agbejade pẹlu awọn ẹgbẹ titẹ sii Bootstrap, iwọ yoo ni lati ṣeto container
aṣayan (ti o ṣe iwe ni isalẹ) lati yago fun awọn ipa ẹgbẹ ti aifẹ.
Ṣe okunfa ohun elo irinṣẹ nipasẹ JavaScript:
- $ ( '#apẹẹrẹ' ). ohun elo ( awọn aṣayan )
Awọn aṣayan le ṣee kọja nipasẹ awọn abuda data tabi JavaScript. Fun awọn abuda data, fi orukọ aṣayan si data-
, bi ninu data-animation=""
.
Oruko | iru | aiyipada | apejuwe |
---|---|---|---|
iwara | boolian | ooto | lo iyipada css ipare si ọpa irinṣẹ |
html | boolian | eke | Fi html sinu ọpa irinṣẹ. Ti o ba jẹ eke, ọna jquery text yoo ṣee lo lati fi akoonu sii sinu dom. Lo ọrọ ti o ba ni aniyan nipa awọn ikọlu XSS. |
ipo | okun | iṣẹ | 'oke' | bi o si ipo awọn Tooltip - oke | isalẹ | osi | ọtun |
yiyan | okun | eke | Ti o ba pese yiyan, awọn ohun elo irinṣẹ yoo jẹ aṣoju si awọn ibi-afẹde pàtó. |
akọle | okun | iṣẹ | '' | iye akọle aiyipada ti tag `akọle` ko ba si |
okunfa | okun | 'fojusi lori' | bawo ni ohun elo irinṣẹ - tẹ | rababa | idojukọ | Afowoyi. Ṣe akiyesi pe ọran kọja nfa mutliple, aaye sọtọ, awọn oriṣi okunfa. |
idaduro | nọmba | nkan | 0 | idaduro fifihan ati fifipamọ awọn ọpa irinṣẹ (ms) - ko kan si iru okunfa afọwọṣe Ti nọmba kan ba pese, idaduro jẹ lilo si tọju/fihan mejeeji Eto nkan jẹ: |
eiyan | okun | eke | eke | Fi ohun elo irinṣẹ si eroja kan pato |
- <a href = "#" data-toggle = "tooltip" akọle = "Tooltip akọkọ" > rababa lori mi </a>
So olutọpa ohun elo kan si ikojọpọ eroja.
Ṣe afihan ohun elo irinṣẹ eroja kan.
- $ ( '# ano' ). ọpa irinṣẹ ( 'ifihan' )
Ìbòmọlẹ ohun ano ká irinṣẹ.
- $ ( '# ano' ). ọpa irinṣẹ ( 'tọju' )
Yipada ohun elo itọsi irinṣẹ.
- $ ( '# ano' ). ọpa irinṣẹ ( 'bayi' )
Hides ati ki o run ohun ano ká irinṣẹ.
- $ ( '# ano' ). ọpa irinṣẹ ( 'run' )
Ṣafikun awọn agbekọja kekere ti akoonu, bii awọn ti o wa lori iPad, si eyikeyi ipin fun alaye Atẹle ile. Raba lori bọtini lati ma nfa popover naa. Nilo Italolobo Irinṣẹ lati wa pẹlu.
Awọn aṣayan mẹrin wa: oke, ọtun, isalẹ, ati ti osi.
Sed posuere consectetur est ni lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur est ni lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur est ni lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur est ni lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Ko si isamisi ti o han bi awọn agbejade ti wa ni ipilẹṣẹ lati JavaScript ati akoonu laarin data
abuda kan.
Mu awọn agbejade ṣiṣẹ nipasẹ JavaScript:
- $ ( '#apẹẹrẹ' ). popover ( awọn aṣayan )
Awọn aṣayan le ṣee kọja nipasẹ awọn abuda data tabi JavaScript. Fun awọn abuda data, fi orukọ aṣayan si data-
, bi ninu data-animation=""
.
Oruko | iru | aiyipada | apejuwe |
---|---|---|---|
iwara | boolian | ooto | lo iyipada css ipare si ọpa irinṣẹ |
html | boolian | eke | Fi html sinu popover. Ti o ba jẹ eke, ọna jquery text yoo ṣee lo lati fi akoonu sii sinu dom. Lo ọrọ ti o ba ni aniyan nipa awọn ikọlu XSS. |
ipo | okun | iṣẹ | 'ọtun' | bi o si ipo awọn popover - oke | isalẹ | osi | ọtun |
yiyan | okun | eke | ti o ba ti pese oluyanju, awọn ohun elo irinṣẹ yoo jẹ aṣoju si awọn ibi-afẹde ti a pato |
okunfa | okun | 'tẹ' | bi popover wa ni jeki - tẹ | rababa | idojukọ | Afowoyi |
akọle | okun | iṣẹ | '' | iye akọle aiyipada ti o ba jẹ pe ẹya 'akọle' ko si |
akoonu | okun | iṣẹ | '' | iye akoonu aiyipada ti ‘akoonu-data’ abuda ko ba si |
idaduro | nọmba | nkan | 0 | idaduro ifihan ati fifipamo popover (ms) - ko kan si iru okunfa afọwọṣe Ti nọmba kan ba pese, idaduro jẹ lilo si tọju/fihan mejeeji Eto nkan jẹ: |
eiyan | okun | eke | eke | Ṣafikun popover si nkan kan pato |
Fun awọn idi iṣẹ ṣiṣe, Ohun elo irinṣẹ ati Agbejade data-apis n wọle. Ti o ba fẹ lati lo wọn kan pato aṣayan yiyan.
Initializes popovers fun ohun akojọpọ eroja.
Ṣe afihan awọn eroja popover.
- $ ( '# ano' ). popover ( 'ifihan' )
Ìbòmọlẹ ohun eroja popover.
- $ ( '# ano' ). popover ( 'tọju' )
Yipada awọn eroja agbejade.
- $ ( '# ano' ). popover ( 'yii' )
Hides ati ki o run ohun ano ká popover.
- $ ( '# ano' ). popover ( 'run' )
Ṣafikun iṣẹ idasile si gbogbo awọn ifiranṣẹ itaniji pẹlu ohun itanna yii.
Yi eyi ati iyẹn pada ki o tun gbiyanju lẹẹkansi. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.
Jeki yiyọ kuro ti itaniji nipasẹ JavaScript:
- $ ( "titaniji" ). gbigbọn ()
Kan ṣafikun data-dismiss="alert"
si bọtini isunmọ rẹ lati funni ni iṣẹ ṣiṣe isunmọ titaniji laifọwọyi.
- <a class = "sunmọ" data-dismiss = "titaniji" href = "#" > & igba; </a>
Murasilẹ gbogbo awọn titaniji pẹlu iṣẹ ṣiṣe to sunmọ. Lati jẹ ki awọn titaniji rẹ gbe jade nigba pipade, rii daju pe wọn ni .fade
ati .in
kilasi ti lo tẹlẹ si wọn.
Tilekun itaniji.
- $ ( "titaniji" ). Itaniji ( 'sunmọ' )
Kilasi gbigbọn Bootstrap ṣafihan awọn iṣẹlẹ diẹ fun sisọ sinu iṣẹ ṣiṣe titaniji.
Iṣẹlẹ | Apejuwe |
---|---|
sunmo | Yi iṣẹlẹ ina lẹsẹkẹsẹ nigbati awọn close apẹẹrẹ ọna ti a npe ni. |
ni pipade | Iṣẹlẹ yii jẹ ina nigbati itaniji ti wa ni pipade (yoo duro fun awọn iyipada css lati pari). |
- $ ( '#mi-ititaniji' ). dè ( 'ni pipade' , iṣẹ () {
- // se nkan…
- })
Gba awọn aza ipilẹ ati atilẹyin to rọ fun awọn paati ikojọpọ bi accordions ati lilọ kiri.
* Nilo ohun itanna Awọn iyipada lati wa pẹlu.
Lilo ohun itanna idapọ, a kọ ẹrọ ailorukọ ara accordion ti o rọrun:
- <div class = "accordion" id = "accordion2" >
- <div class = "accordion-group" >
- <div class = "accordion-heading" >
- <a class = "accordion-toggle" data-toggle = "collapse" data-parent = "#accordion2" href = "#collapseOne" >
- Collapsible Ẹgbẹ Nkan # 1
- </a>
- </div>
- <div id = "collapseOne" kilasi = "accordion-body Collapse ni" >
- <div class = "accordion-inner" >
- Animu pariatur cliche...
- </div>
- </div>
- </div>
- <div class = "accordion-group" >
- <div class = "accordion-heading" >
- <a class = "accordion-toggle" data-toggle = "collapse" data-parent = "#accordion2" href = "#collapseTwo" >
- Collapsible Ẹgbẹ Nkan #2
- </a>
- </div>
- <div id = "collapseTwo" kilasi = "accordion-body Collapse" >
- <div class = "accordion-inner" >
- Animu pariatur cliche...
- </div>
- </div>
- </div>
- </div>
- ...
O tun le lo ohun itanna laisi ami ami accordion. Ṣe bọtini kan yi iyipada ti o pọ si ati fifọ ti nkan miiran.
- <button type = "bọtini" kilasi = "btn btn-danger" data-toggle = "collapse" data-target = "#demo" >
- o rọrun collapsible
- </bọtini>
- <div id = "demo" kilasi = "kolula sinu" > … </div>
Kan ṣafikun data-toggle="collapse"
ati ipin data-target
kan lati fi iṣakoso laifọwọyi ti nkan kan ti o le kọlu. Ẹya naa data-target
gba oluyan css kan lati lo iṣubu si. Rii daju lati ṣafikun kilasi collapse
naa si nkan ti o le ṣubu. Ti o ba fẹ ki o ṣii aiyipada, ṣafikun afikun kilasi in
.
Lati ṣafikun iṣakoso ẹgbẹ bi accordion si iṣakoso ikojọpọ, ṣafikun abuda data naa data-parent="#selector"
. Tọkasi demo lati wo eyi ni iṣe.
Mu ṣiṣẹ pẹlu ọwọ pẹlu:
- $ ( ".collapse" ). ṣubu ()
Awọn aṣayan le ṣee kọja nipasẹ awọn abuda data tabi JavaScript. Fun awọn abuda data, fi orukọ aṣayan si data-
, bi ninu data-parent=""
.
Oruko | iru | aiyipada | apejuwe |
---|---|---|---|
obi | yiyan | eke | Ti o ba yan lẹhinna gbogbo awọn eroja ti o le kojọpọ labẹ obi ti a ti sọ ni yoo wa ni pipade nigbati ohun kan ti o le kọlu ba han. (bii iwa accordion ibile) |
yipada | boolian | ooto | Yipada eroja ti o le kolu lori ẹbẹ |
Mu akoonu rẹ ṣiṣẹ bi eroja ti o le kolu. Gba awọn aṣayan iyan object
.
- $ ( '#myCollapsible' ). ṣubu ({
- toggle : iro
- })
Yipada eroja ti o le kolu lati ṣafihan tabi pamọ.
Ṣe afihan eroja ti o le ṣubu.
Ìbòmọlẹ ohun kan collapsible.
Kilasi Collapse Bootstrap ṣafihan awọn iṣẹlẹ diẹ fun sisọ sinu iṣẹ ṣiṣe iṣubu.
Iṣẹlẹ | Apejuwe |
---|---|
ifihan | Yi iṣẹlẹ ina lẹsẹkẹsẹ nigbati awọn show apẹẹrẹ ọna ti a npe ni. |
han | Iṣẹlẹ yii jẹ ina nigba ti a ti jẹ ki ohun elo iṣubu kan han si olumulo (yoo duro fun awọn iyipada css lati pari). |
tọju | Yi iṣẹlẹ ti wa ni kuro lenu ise lẹsẹkẹsẹ nigbati awọn hide ọna ti a ti a npe ni. |
farasin | Iṣẹlẹ yii jẹ ina nigba ti ohun elo iṣubu kan ti farapamọ lati ọdọ olumulo (yoo duro fun awọn iyipada css lati pari). |
- $ ( '#myCollapsible' ). lori ( 'farasin' , iṣẹ () {
- // se nkan…
- })
Ni agbelera ni isalẹ fihan ohun itanna jeneriki ati paati fun gigun kẹkẹ nipasẹ awọn eroja bii carousel kan.
- <div id = "myCarousel" kilasi = " ifaworanhan carousel " >
- <ol kilasi = "carousel-itọkasi" >
- <li data-target = "#myCarousel" data-slide-to = "0" kilasi = "lọwọ" </li>
- <li data-target = "#myCarousel" data-slide-to = "1" </li>
- <li data-target = "#myCarousel" data-slide-to = "2" </li>
- </ol>
- <!-- Awọn nkan Carousel -->
- <div class = "carousel-inner" >
- <div class = "ohun ti nṣiṣe lọwọ" > … </div>
- <div class = "ohun kan" > … </div>
- <div class = "ohun kan" > … </div>
- </div>
- <!-- Carousel nav -->
- <a class = "carousel-control osi" href = "#myCarousel" data-slide = "prev" > ‹ </a>
- <a class = "carousel-control right" href = "#myCarousel" data-slide = "tókàn" > & rsaquo; </a>
- </div>
Lo awọn abuda data lati ṣakoso ni irọrun ipo ti carousel. data-slide
gba awọn koko-ọrọ prev
tabi next
, eyiti o paarọ ipo ifaworanhan ni ibatan si ipo lọwọlọwọ. Ni omiiran, lo data-slide-to
lati kọja atọka ifaworanhan aise si carousel data-slide-to="2"
, eyiti o fo ni ipo ifaworanhan si atọka kan pato ti o bẹrẹ pẹlu 0
.
Pe carousel pẹlu ọwọ pẹlu:
- $ ( '.carousel' ). carousel ()
Awọn aṣayan le ṣee kọja nipasẹ awọn abuda data tabi JavaScriptz. Fun awọn abuda data, fi orukọ aṣayan si data-
, bi ninu data-interval=""
.
Oruko | iru | aiyipada | apejuwe |
---|---|---|---|
aarin | nọmba | 5000 | Iye akoko lati ṣe idaduro laarin gigun kẹkẹ ohun kan laifọwọyi. Ti o ba jẹ eke, carousel kii yoo yipo laifọwọyi. |
da duro | okun | "rababa" | Ṣe idaduro gigun kẹkẹ ti carousel lori mouseenter ati tun bẹrẹ gigun kẹkẹ ti carousel lori mouseleave. |
Ti bẹrẹ carousel pẹlu awọn aṣayan iyan object
ati bẹrẹ gigun kẹkẹ nipasẹ awọn ohun kan.
- $ ( '.carousel' ). carousel ({
- aarin : 2000
- })
Yiyipo nipasẹ awọn ohun carousel lati osi si otun.
Da carousel duro lati gigun kẹkẹ nipasẹ awọn ohun kan.
Yi kẹkẹ carousel lọ si fireemu kan pato (orisun 0, iru si orun).
Awọn iyipo si nkan ti tẹlẹ.
Awọn iyipo si nkan atẹle.
Kilasi carousel Bootstrap ṣafihan awọn iṣẹlẹ meji fun sisọ sinu iṣẹ ṣiṣe carousel.
Iṣẹlẹ | Apejuwe |
---|---|
ifaworanhan | Iṣẹlẹ yii ina lẹsẹkẹsẹ nigbati ọna slide apẹẹrẹ ba pe. |
sisun | Iṣẹlẹ yii jẹ ina nigbati carousel ti pari iyipada ifaworanhan rẹ. |
Ipilẹ kan, ohun itanna ti o gbooro ni irọrun fun ṣiṣẹda ni iyara awọn oriṣi ti o wuyi pẹlu titẹ ọrọ fọọmu eyikeyi.
- <input type = "text" data-provide = "typeahead" >
Iwọ yoo fẹ lati ṣeto autocomplete="off"
lati yago fun awọn akojọ aṣayan aṣawakiri aiyipada lati han lori sisọ silẹ typeahead Bootstrap.
Ṣafikun awọn abuda data lati forukọsilẹ nkan kan pẹlu iṣẹ ṣiṣe oriṣi bi o ṣe han ninu apẹẹrẹ loke.
Pe typehead pẹlu ọwọ pẹlu:
- $ ( '.typehead' ). oriṣi ori ()
Awọn aṣayan le ṣee kọja nipasẹ awọn abuda data tabi JavaScript. Fun awọn abuda data, fi orukọ aṣayan si data-
, bi ninu data-source=""
.
Oruko | iru | aiyipada | apejuwe |
---|---|---|---|
orisun | orun, iṣẹ | [] | Orisun data lati beere lodi si. O le jẹ akojọpọ awọn okun tabi iṣẹ kan. Iṣẹ naa ti kọja awọn ariyanjiyan meji, query iye ninu aaye titẹ sii ati process ipe pada. Iṣẹ naa le ṣee lo ni irẹpọ nipa mimu-pada sipo orisun data taara tabi asynchronously nipasẹ ariyanjiyan process ipepada nikan. |
awọn nkan | nọmba | 8 | Nọmba ti o pọju awọn ohun kan lati ṣafihan ninu sisọ silẹ. |
Ipari min | nọmba | 1 | Gigun ohun kikọ to kere julọ nilo ṣaaju ṣiṣe awọn didaba adaṣe pipe |
baramu | iṣẹ | irú insensitive | Ọna ti a lo lati pinnu boya ibeere kan ba nkan kan mu. Gba ariyanjiyan ẹyọkan, item lodi si eyiti lati ṣe idanwo ibeere naa. Wọle si ibeere lọwọlọwọ pẹlu this.query . Da boolean pada true ti ibeere ba jẹ baramu. |
lẹsẹsẹ | iṣẹ | baramu gangan, ọran ifarabalẹ, ọran aibikita |
Ọna ti a lo lati to awọn abajade pipe laifọwọyi. Gba ariyanjiyan ẹyọkan items ati pe o ni aaye ti apẹẹrẹ iruhead. Tọkasi ibeere lọwọlọwọ pẹlu this.query . |
imudojuiwọn | iṣẹ | pada ti a ti yan ohun kan | Ọna ti a lo lati da ohun ti o yan pada. Gba kan nikan ariyanjiyan, awọn item ati ki o ni awọn dopin ti iruhead apeere. |
afihan | iṣẹ | ṣe afihan gbogbo awọn ibaamu aiyipada | Ọna ti a lo lati ṣe afihan awọn abajade adaṣe. Gba ariyanjiyan ẹyọkan item ati pe o ni aaye ti apẹẹrẹ iruhead. O yẹ ki o pada html. |
Ti bẹrẹ igbewọle kan pẹlu ori oriṣi.
Subnavigation ti o wa ni apa osi jẹ demo ifiwe ti ohun itanna affix.
Lati fi irọrun ṣafikun ihuwasi affix si eyikeyi eroja, kan ṣafikun data-spy="affix"
si ipin ti o fẹ ṣe amí lori. Lẹhinna lo awọn aiṣedeede lati ṣalaye nigbati o ba yipada pinning ti nkan kan tan ati pipa.
- <div data-spy = "affix" data-offset-top = "200" > ... </div>
affix
,
affix-top
, ati
affix-bottom
. Ranti lati ṣayẹwo fun obi ti o le ṣubu nigbati ifisi ba bẹrẹ bi o ṣe n yọ akoonu kuro lati ṣiṣan deede ti oju-iwe naa.
Pe ohun itanna affix nipasẹ JavaScript:
- $ ( '#navbar' ). so ()
Awọn aṣayan le ṣee kọja nipasẹ awọn abuda data tabi JavaScript. Fun awọn abuda data, fi orukọ aṣayan si data-
, bi ninu data-offset-top="200"
.
Oruko | iru | aiyipada | apejuwe |
---|---|---|---|
aiṣedeede | nọmba | iṣẹ | nkan | 10 | Awọn piksẹli lati aiṣedeede lati iboju nigbati o ṣe iṣiro ipo ti yi lọ. Ti o ba pese nọmba kan, aiṣedeede yoo lo ni oke ati awọn itọnisọna osi. Lati tẹtisi itọsọna kan, tabi awọn aiṣedeede alailẹgbẹ pupọ, kan pese ohun kan offset: { x: 10 } . Lo iṣẹ kan nigbati o nilo lati pese aiṣedeede kan (wulo fun diẹ ninu awọn aṣa idahun). |