Bootstrap in fɔm kɔntrol dɛn de ɛkspɛn pan wi Ribɔt fɔm stayl dɛn wit klas dɛn. Yuz dɛn klas ya fɔ opt insay dɛn kɔstɔmayt displei fɔ wan mɔ kɔnsistɛns rɛnda akɔdin to brɔwza ɛn divays dɛn.
Mek shɔ se yu yuz wan typeatribyut we fit pan ɔl di input dɛn (ɛgz., emailfɔ imel adrɛs ɔ numberfɔ nɔmba infɔmeshɔn) fɔ tek advantej pan nyu input kɔntrol dɛn lɛk imel verifyeshɔn, nɔmba sɛlɛkshɔn, ɛn ɔda tin dɛn.
Na wan kwik ɛgzampul fɔ sho Bootstrap in fɔm stayl dɛn. Kɔntinyu fɔ rid fɔ gɛt dɔkyumɛnt dɛn bɔt di klas dɛn we dɛn nid, fɔm layout, ɛn ɔda tin dɛn.
Fɔm kɔntrol dɛn
Di tɛkstual fɔm kɔntrol dɛn—lɛk <input>s, <select>s, ɛn <textarea>s—dɛn stayl dɛn wit di .form-controlklas. Insay de, dɛn gɛt stayl dɛn fɔ di we aw pɔsin de luk, di we aw pɔsin de pe atɛnshɔn, di sayz we i de, ɛn ɔda tin dɛn.
Mek shɔ se yu fɛn wi kɔstɔm fɔm dɛn fɔ mek yu gɛt mɔ stayl <select>s.
Fɔ fayl input dɛn, swap di .form-controlfɔ .form-control-file.
Sayz fɔ di sayz
Sɛt ayt dɛn yuz klas dɛn lɛk .form-control-lgɛn .form-control-sm.
Na fɔ rid nɔmɔ
Ad di readonlyboolean atribyut pan wan input fɔ mek dɛn nɔ chenj di input in valyu. Di input dɛn we yu kin rid nɔmɔ kin tan lɛk layt (jɔs lɛk di input dɛn we dɛn dɔn disable), bɔt dɛn kin kip di standad kɔsa.
Na wan klin tɛks nɔmɔ fɔ rid
If yu want fɔ gɛt <input readonly>ɛlimɛnt dɛn na yu fɔm we dɛn stayl lɛk plein tɛks, yuz di .form-control-plaintextklas fɔ pul di difɔlt fɔm fil stayl ɛn kip di kɔrɛkt margin ɛn pad.
Rɛnj Input dɛn
Set ɔrizɔntal skrol rɛnj input dɛn yuz .form-control-range.
Chɛkbɔks dɛn ɛn redio dɛn
Difɔlt chɛkbɔks ɛn redio dɛn de impɔtant wit di ɛp fɔ .form-check, wan klas fɔ ɔl tu di kayn input dɛn we de mek di layout ɛn bihayvya fɔ dɛn HTML ɛlimɛnt dɛn bɛtɛ . Chɛkbɔks dɛn na fɔ pik wan ɔ sɔm tin dɛn we de na wan list, ɛn redio dɛn na fɔ pik wan tin dɛn frɔm bɔku pan dɛn.
Dɛn de sɔpɔt chɛkbɔks ɛn redio dɛn we nɔ ebul fɔ wok. Di disabledatribyut go aplay layt kala fɔ ɛp fɔ sho di input in stet.
Chɛkbɔks ɛn redio bɔtin dɛn de sɔpɔt HTML-based fɔm validɛshɔn ɛn dɛn de gi kɔrɛkt, aksesbul lɛbl dɛn. As a so, wi <input>s ɛn <label>s na brɔda ɛn sista ɛlimɛnt dɛn as opɔz to wan <input>insay wan <label>. Dis na smɔl mɔ verbose as yu fɔ spɛsifa idɛn foratribyut dɛn fɔ rilayt di <input>ɛn <label>.
Difɔlt (we dɛn dɔn stak) .
Bay difɔlt, ɛni nɔmba fɔ chɛkbɔks ɛn redio dɛn we na brɔda ɛn sista dɛn we de nia dɛnsɛf go de vertikal wan ɛn dɛn go put dɛn spɛshal say wit .form-check.
Inlayn
Grup chɛkbɔks ɔ redio dɛn na di sem ɔrizɔntal row bay we yu ad .form-check-inlineto ɛni wan pan dɛn .form-check.
Wi nɔ gɛt lɛbl dɛn
Ad .position-staticto inputs insay .form-checkwe nɔ gɛt ɛni lɛbul tɛks. Mɛmba fɔ stil gi sɔm kayn lɛbl fɔ ɛp tɛknɔlɔji dɛn (fɔ ɛgzampul, yuz aria-label).
Dizayn
Bikɔs Bootstrap de aplay display: blockɛn width: 100%to ɔlmost ɔl wi fɔm kɔntrol dɛn, fɔm dɛn go bay difɔlt stak vertikal. Yu kin yuz ɔda klas dɛn fɔ chenj dis layout pan ɛni fɔm.
Fɔm grup dɛn
Di .form-groupklas na di izi we fɔ ad sɔm strɔkchɔ to fɔm dɛn. I de gi wan fleksibul klas we de ɛnkɔrej fɔ grup di rayt lɛbl dɛn, kɔntrol dɛn, opshɔnal ɛp tɛks, ɛn fɔm validɛshɔn mɛsej. Bay difɔlt i jɔs de aplay margin-bottom, bɔt i de pik ɔda stayl dɛn insay .form-inlineas nid de. Yuz am wit <fieldset>s, <div>s, ɔ nia ɛni ɔda ɛlimɛnt.
Fɔm grid fɔm
Yu kin bil mɔ kɔmpleks fɔm dɛn we yu de yuz wi grid klas dɛn. Yuz dɛn wan ya fɔ fɔm layout dɛn we nid bɔku kɔlɔm dɛn, difrɛn wit dɛn, ɛn ɔda alaynɛshɔn opshɔn dɛn.
Fɔm row
Yu kin chenj bak .rowfɔ .form-row, wan chenj fɔ wi standad grid row we de ɔvalayz di difɔlt kɔlɔm gɔta dɛn fɔ tayt ɛn mɔ kɔmpakt layout dɛn.
Yu kin mek mɔ kɔmpleks layout dɛn bak wit di grid sistem.
Ɔrizɔntal fɔm
Krio ɔrizɔntal fɔm dɛn wit di grid bay we yu ad di .rowklas to fɔm grup dɛn ɛn yuz di .col-*-*klas dɛn fɔ sho di wit fɔ yu lɛbl ɛn kɔntrol dɛn. Mek shɔ se yu ad .col-form-labelto yu <label>s bak so dɛn de vertikal sɛntrɛd wit dɛn asosiet fɔm kɔntrol dɛn.
Sɔntɛnde, yu go nid fɔ yuz margin ɔ padding utilities fɔ mek da pafɛkt alaynɛshɔn de we yu nid. Fɔ ɛgzampul, wi dɔn pul di padding-toppan wi stak redio input dɛn lɛbl fɔ mek di tɛks beslayn alaynɛd fayn fayn wan.
Ɔrizɔntal fɔm lɛbl saiz
Mek shɔ se yu yuz .col-form-label-smɔ .col-form-label-lgto yu <label>s ɔ <legend>s fɔ fala di sayz fɔ .form-control-lgɛn kɔrɛkt wan .form-control-sm.
Di sayz fɔ di kɔlɔm dɛn
As wi bin dɔn sho na di ɛgzampul dɛn we dɔn pas, wi grid sistem de mek yu ebul fɔ put ɛni nɔmba fɔ .cols insay wan .rowɔ .form-row. Dem go split di avaylabl width ikwal bitwin dem. Yu kin pik wan sɔbsɛt bak pan yu kɔlɔm dɛn fɔ tek mɔ ɔ smɔl ples, we di ɔda .colwan dɛn we lɛf ikwal split di ɔda wan dɛn, wit sɔm patikyula kɔlɔm klas dɛn lɛk .col-7.
Awto-sayz
Di ɛgzampul we de dɔŋ ya de yuz wan fleksbɔks yutiliti fɔ sɛnt di tin dɛn we de insay vertikal wan ɛn chenj .colto .col-autoso dat yu kɔlɔm dɛn go jɔs tek bɔku ples we dɛn nid. If wi put am ɔda we, di kɔlɔm de saiz insɛf bay di tin dɛn we de insay.
Dɔn yu kin rimiks dat wan tɛm bak wit saiz-spɛsifi k kɔlɔm klas dɛn.
Yuz di .form-inlineklas fɔ sho wan siriɔs lɛbl, fɔm kɔntrol, ɛn bɔtin dɛn na wan ɔrizɔntal rɔw. Fɔm kɔntrol dɛn insay inlayn fɔm dɛn kin difrɛn smɔl frɔm dɛn difɔlt stet dɛn.
Kɔntrol dɛn na display: flex, we de kɔlap ɛni HTML wayt spɛs ɛn alaw yu fɔ gi alaynɛshɔn kɔntrol wit spɛshal ɛn fleksbɔks yutiliti dɛn.
Kɔntrol ɛn input grup dɛn de gɛt width: autofɔ ɔvalayz di Bootstrap difɔlt width: 100%.
Kɔntrol dɛn jɔs de apia inlayn na viupɔt dɛn we at le 576px waid fɔ akɔn fɔ smɔl smɔl viupɔt dɛn na mobayl divays dɛn.
Yu kin nid fɔ adrɛs wit yu an di wit ɛn alaynɛshɔn fɔ wan wan fɔm kɔntrol dɛn wit spɛshal yutiliti dɛn (as dɛn sho dɔŋ ya). Las wan, mek shɔ se yu put wan ɔltɛm <label>wit ɛni fɔm kɔntrol, ivin if yu nid fɔ ayd am frɔm pipul dɛn we nɔ de rid di skrin wit .sr-only.
Kɔstɔm fɔm kɔntrol ɛn sɛlɛkshɔn dɛn de sɔpɔt bak.
Ɔda tin dɛn we dɛn kin yuz fɔ mek lɛbl dɛn we dɛn ayd
Asisten teknɔlɔji dɛn lɛk skrin rida dɛn go gɛt prɔblɛm wit yu fɔm dɛn if yu nɔ put lɛbl fɔ ɛvri input. Fɔ dɛn inlayn fɔm dɛn ya, yu kin ayd di lɛbl dɛn we yu de yuz di .sr-onlyklas. Ɔda we dɛn de fɔ gi lɛbl fɔ ɛp tɛknɔlɔji dɛn, lɛk di aria-label, aria-labelledbyɔ titleatribyut. If nɔbɔdi pan dɛn tin ya nɔ de, ɛp tɛknɔlɔji dɛn kin yuz di placeholderatribyut, if i de, bɔt notis se placeholderdɛn nɔ advays fɔ yuz am as ples fɔ ɔda we dɛn fɔ lɛbul.
Ɛp tɛks
Blɔk-lɛvel ɛp tɛks insay fɔm dɛn kin mek yuz .form-text(we dɛn bin de kɔl bifo tɛm as .help-blockinsay v3). Inlayn ɛp tɛks kin fleksibul implimɛnt yuz ɛni inlayn HTML ɛlimɛnt ɛn yutiliti klas dɛn lɛk .text-muted.
Fɔ jɔyn ɛp tɛks wit fɔm kɔntrol dɛn
Ɛp tɛks fɔ gɛt sɔntin fɔ du wit di fɔm kɔntrol we i gɛt fɔ du wit fɔ yuz di aria-describedbyatribyut. Dis go mek shɔ se di ɛtɛknɔlɔji dɛn we de ɛp—lɛk di wan dɛn we de rid di skrin—go anɔys dis ɛp tɛks we di pɔsin we de yuz am de pe atɛnshɔn ɔ go insay di kɔntrol.
Ɛp tɛks we de dɔŋ di input dɛn kin stayl wit .form-text. Dis klas inklud display: blockɛn ad sɔm tɔp margin fɔ izi spɛshal frɔm di input dɛn we de ɔp.
Yu paswɔd fɔ lɔng 8-20 aks, i fɔ gɛt lɛta ɛn nɔmba dɛn, ɛn i nɔ fɔ gɛt spɛshal aks dɛn, ɔ imɔji dɛn.
Inlayn tɛks kin yuz ɛni tipik inlayn HTML ɛlimɛnt (ilɛksɛf na <small>, <span>, ɔ ɔda tin) we nɔ gɛt natin pas yutiliti klas.
Fɔm dɛn we gɛt disabled
Ad di disabledboolean atribyut pan wan input fɔ mek yuz nɔ intarakshɔn ɛn mek i tan lɛk layt.
Ad di disabledatribyut to a <fieldset>fɔ disable ɔl di kɔntrol dɛn we de insay.
Caveat wit ankɔ dɛn
Bay difɔlt, brawza dɛn go trit ɔl di nativ fɔm kɔntrol dɛn ( <input>, <select>ɛn <button>ɛlimɛnt dɛn) insay a <fieldset disabled>as disabled, we go mek ɔl tu di kibɔd ɛn maws intarakshɔn pan dɛn. Bɔt if yu fɔm gɛt <a ... class="btn btn-*">ɛlimɛnt dɛn bak, dɛn go jɔs gi dɛn wan ya wan stayl we na pointer-events: none. As wi bin dɔn tɔk na di sɛkshɔn bɔt disabled stet fɔ bɔtin dɛn (ɛn spɛshal wan na di sab-sɛkshɔn fɔ ankɔ ɛlimɛnt dɛn), dis CSS prɔpati nɔ standad yet ɛn i nɔ fulɔp fɔ sɔpɔt am na Intanɛt Ɛksplɔrɔ 10, ɛn i nɔ go mek di wan dɛn we de yuz di kibɔd nɔ ebul fɔ du dat ebul fɔ fos ɔ aktiv dɛn link dɛn ya. So fɔ mek yu sef, yuz kɔstɔm JavaSkript fɔ disable dɛn kayn link dɛn de.
Krɔs-brauza kɔmpitibliti
Pan ɔl we Bootstrap go yuz dɛn stayl dɛn ya na ɔl di brawza dɛn, Intanɛt Ɛksplɔrɔ 11 ɛn dɔŋ ya nɔ de sɔpɔt di disabledatribyut ɔlsay na wan <fieldset>. Yuz kɔstɔm JavaSkript fɔ disable di fil sɛt na dɛn brɔuza dɛn ya.
Validɛshɔn fɔ di wok
Gi valyu, akshɔnable fidbak to yu yuza dɛn wit HTML5 fɔm validɛshɔn– we de na ɔl wi brawza dɛn we wi sɔpɔt . Pik frɔm di brawza difɔlt validɛshɔn fidbak, ɔ impruv kɔstɔm mɛsej dɛn wit wi bilt-in klas dɛn ɛn stata JavaSkript.
Naw wi de advays yu fɔ yuz kɔstɔm validɛshɔn stayl dɛn, bikɔs nativ brawza difɔlt validɛshɔn mɛsej dɛn nɔ kin de ɔltɛm fɔ ɛp tɛnkɔlɔji dɛn na ɔl di brawza dɛn (mɔs mɔ, Chrome na dɛsktɔp ɛn mobayl).
Aw i de wok
Na so fɔm validɛshɔn de wok wit Bootstrap:
HTML fɔm validɛshɔn de aplay via CSS in tu pseudo-klas dɛn, :invalidɛn :valid. I de aplay to <input>, <select>, ɛn <textarea>ɛlimɛnt dɛn.
Bootstrap de skɔp di :invalidɛn :validstayl dɛn to mama ɛn papa .was-validatedklas, dɛn kin yuz am fɔ di <form>. If nɔto dat, ɛni fil we dɛn nid we nɔ gɛt valyu go sho se i nɔ rayt we dɛn de lod di pej. Dis we ya, yu kin pik ustɛm fɔ aktiv dɛn (tipikli afta dɛn dɔn tray fɔ sɛn fɔm).
Fɔ riset di apinɛns fɔ di fɔm (fɔ ɛgzampul, insay di kes fɔ dinamik fɔm sɔbmishɔn dɛn we yu de yuz AJAX), pul di .was-validatedklas frɔm di <form>bak afta sɔbmishɔn.
As fɔl bak, .is-invalidɛn .is-validklas dɛn kin yuz instead ɔf di pseudo-klas fɔ sava sayd validɛshɔn . Dɛn nɔ nid fɔ gɛt .was-validatedmama ɛn papa dɛn klas.
Bikɔs ɔf kɔnstrakshɔn dɛn na aw CSS de wok, wi nɔ go ebul (naw) fɔ yuz stayl dɛn to wan <label>we de kam bifo wan fɔm kɔntrol na di DOM if dɛn nɔ ɛp di kɔstɔm JavaSkript.
Ɔl di mɔdan brawza dɛn de sɔpɔt di kɔnstrakshɔn validɛshɔn API , we na wan siriɔs JavaSkript we fɔ validet fɔm kɔntrol dɛn.
Fidbak mɛsej dɛn kin yuz di brɔwza difɔlt dɛn (difrɛn fɔ ɛni brawza, ɛn dɛn nɔ kin stayl am bay CSS) ɔ wi kɔstɔm fidbak stayl dɛn wit ɔda HTML ɛn CSS.
Yu kin gi kɔstɔm validiti mɛsej dɛn wit setCustomValidityinsay JavaSkript.
Wit dat in maynd, tink bɔt di demo dɛn we de dɔŋ ya fɔ wi kɔstɔm fɔm validɛshɔn stayl dɛn, opshɔnal sava sayd klas dɛn, ɛn brawza difɔlt dɛn.
Kastom stayl dɛn
Fɔ kɔstɔm Bootstrap fɔm validɛshɔn mɛsej dɛn, yu go nid fɔ ad di novalidatebuli atribyut to yu <form>. Dis de mek di brɔwza difɔlt fidbak tultip dɛn nɔ wok, bɔt stil de gi yu akses to di fɔm validɛshɔn API dɛn na JavaSkript. Tray fɔ sɛn di fɔm we de dɔŋ ya; wi JavaSkript go intasept di sɔbmit bɔtin ɛn rilay fidbak to yu. We yu de tray fɔ sɛn, yu go si di :invalidɛn :validstayl dɛn we dɛn yuz fɔ yu fɔm kɔntrol dɛn.
Yu nɔ intres pan kɔstɔm validɛshɔn fidbak mɛsej ɔ rayt JavaSkript fɔ chenj fɔm bihayvya? Ɔl gud, yu kin yuz di brɔwza difɔlt dɛn. Tray fɔ sɛn di fɔm we de dɔŋ ya. Dipen pan yu brawza ɛn OS, yu go si difrɛn stayl fɔ fidbak smɔl.
Pan ɔl we dɛn fidbak stayl ya nɔ go ebul fɔ stayl wit CSS, yu kin stil kɔstɔmayz di fidbak tɛks tru JavaSkript.
Serva sayd
Wi kin advays yu fɔ yuz klaynt-sayd validɛshɔn, bɔt if yu nid fɔ validɛshɔn na di sava-sayd, yu kin sho di fɔm fil dɛn we nɔ valid ɛn we valid wit .is-invalidɛn .is-valid. Notis se .invalid-feedbackdɛn de sɔpɔt bak wit dɛn klas ya.
Elemɛnt dɛn we dɛn sɔpɔt
Validɛshɔn stayl dɛn de fɔ di fɔm kɔntrol ɛn kɔmpɔnɛnt dɛn we de dɔŋ ya:
<input>s ɛn <textarea>s wit .form-control(inklud te to wan .form-controlinsay input grup dɛn)
<select>s wit .form-controlɔ.custom-select
.form-checks
.custom-checkboxs ɛn .custom-radios
.custom-file
Tultip dɛn fɔ yuz
If yu fɔm layout alaw am, yu kin swap di .{valid|invalid}-feedbackklas dɛn fɔ .{valid|invalid}-tooltipklas dɛn fɔ sho validɛshɔn fidbak insay wan stayl tultip. Mek shɔ se yu gɛt mama ɔ papa wit position: relativepan am fɔ tultip pozishɔn. Insay di ɛgzampul we de dɔŋ ya, wi kɔlɔm klas dɛn dɔn ɔlrɛdi gɛt dis, bɔt yu prɔjek kin nid fɔ gɛt ɔda sɛtup.
Fɔ kɔstɔmayt
Valideshɔn stet dɛn kin kɔstɔmayz via Sass wit di $form-validation-statesmap. Na wi _variables.scssfayl, dis Sass map de loop ova fɔ jenarayz di difɔlt valid/ invalidvalidɛshɔn stet dɛn. Insay de, dɛn gɛt wan map we dɛn dɔn nɛst fɔ kɔstɔmayt ɛni stet in kɔlɔ ɛn aykɔn. Pan ɔl we no ɔda stet nɔ de we brawza de sɔpɔt, di wan dɛn we de yuz kɔstɔm stayl dɛn kin ad mɔ kɔmpleks fɔm fidbak izi wan.
Duya mɛmba se wi nɔ de advays fɔ kɔstɔmayt dɛn valyu ya we yu nɔ chenj di form-validation-statemixin bak.
Kɔstɔm fɔm dɛn
Fɔ ivin mɔ kɔstɔmayshɔn ɛn krɔs brawza kɔnsistɛns, yuz wi kɔmplit kɔstɔm fɔm ɛlimɛnt dɛn fɔ riples di brɔwza difɔlt dɛn. Dɛn bil dɛn pan ɔp sɛmantik ɛn aksesbul mak, so dɛn na sɔlid riplesmɛnt fɔ ɛni difɔlt fɔm kɔntrol.
Chɛkbɔks dɛn ɛn redio dɛn
Ɛni chɛkbɔks ɛn redio <input>ɛn <label>pairing de rap insay wan <div>fɔ mek wi kɔstɔm kɔntrol. Structurally, dis na di sem we aw wi de du am difɔlt .form-check.
Wi de yuz di brɔda ɛn sista sɛlɛktɔ ( ~) fɔ ɔl wi <input>stet dɛn—lɛk :checked—fɔ stayl wi kɔstɔm fɔm indikɛtɔ fayn fayn wan. We wi jɔyn wit di .custom-control-labelklas, wi kin stayl di tɛks bak fɔ ɛni tin bay di <input>’s stet.
Wi de ayd di difɔlt <input>wit opacityɛn yuz di .custom-control-labelfɔ bil nyu kɔstɔm fɔm indikɛtɔ na in ples wit ::beforeɛn ::after. Na ɔnfɔni wi nɔ ebul fɔ bil kɔstɔm wan frɔm jɔs di <input>bikɔs CSS's contentnɔ de wok pan da ɛlimɛnt de.
Insay di stet dɛn we dɛn chɛk, wi de yuz base64 ɛmbaded SVG aykɔn dɛn frɔm Open Iconic . Dis de gi wi di bɛst kɔntrol fɔ stayl ɛn pozishɔn akɔdin to brawza ɛn divays dɛn.
Chɛkbɔks dɛn
Kastom chɛkbɔks dɛn kin yuz di :indeterminatepseudo klas bak we dɛn sɛt wit dɛn an bay JavaSkript (no HTML atribyut nɔ de fɔ spɛsifa am).
If yu de yuz jQuery, sɔntin lɛk dis fɔ du fɔ:
Redio dɛn
Inlayn
Disebul
Yu kin disable di kɔstɔm chɛkbɔks ɛn redio dɛn bak. Ad di disabledboolean atribyut to di <input>ɛn di kɔstɔm indikɛtɔ ɛn di lɛbl diskripshɔn go ɔtomɛtik stayl.
Switch dɛn
Swich gɛt di mak fɔ wan kɔstɔm chɛkbɔks bɔt i de yuz di .custom-switchklas fɔ rɛnd wan tɔgl switch. Switch dɛn de sɔpɔt di disabledatribyut bak.
Pik di mɛnyu
Kastom <select>mɛnyu dɛn nid jɔs wan kɔstɔm klas, .custom-selectfɔ trig di kɔstɔm stayl dɛn. Di kɔstɔm stayl dɛn de fɔ di <select>'s fɔs apinɛns ɛn dɛn nɔ go ebul fɔ chenj di <option>s bikɔs di brɔwza nɔ gɛt bɛtɛ tin fɔ du.
Yu kin pik bak frɔm smɔl ɛn big kɔstɔm sɛlɛkshɔn dɛn fɔ mach wi tɛks input dɛn we gɛt di sem sayz.
Di multipleatribyut de sɔpɔt bak:
As na di sizeatribyut:
Te
Krio kɔstɔm <input type="range">kɔntrol dɛn wit .custom-range. Di trak (di bakgrɔn) ɛn di tumbu (di valyu) dɛn ɔl tu stayl fɔ mek dɛn sho di sem akɔdin to di brɔuza dɛn. As na IE ɛn Fayafaks nɔmɔ de sɔpɔt fɔ “fil” dɛn trak frɔm di lɛft ɔ rayt pat na di thumb as we fɔ sho se dɛn de go bifo, wi nɔ de sɔpɔt am naw.
Rɛnj input dɛn gɛt implisit valyu fɔ minɛn max— 0ɛn 100, rispɛktvɔli. Yu kin sho nyu valyu dɛn fɔ di wan dɛn we de yuz di minɛn maxatribyut dɛn.
Bay difɔlt, rɛnj input dɛn “snap” to intaj valyu dɛn. Fɔ chenj dis, yu kin sho wan stepvalyu. Insay di ɛgzampul we de dɔŋ ya, wi de dubl di nɔmba fɔ di stɛp dɛn bay we wi yuz step="0.5".
Fayl brawza
Di plɔgin we dɛn rɛkɔmɛnd fɔ animat kɔstɔm fayl input: bs-kɔstɔm-fayl-input , na dat wi de yuz naw ya na wi dɔks.
Di fayl input na di wan we gnarly pas ɔl pan di bɔnch ɛn i nid fɔ gɛt ɔda JavaSkript if yu want fɔ huk dɛn wit funkshɔn Choose fayl... ɛn fayl nem tɛks we yu dɔn pik.
Wi de ayd di difɔlt fayl <input>via opacityɛn insted stayl di <label>. Di bɔtin de jenarayz ɛn posishun wit ::after. Las las, wi deklare a widthɛn heightpan di <input>fɔ di rayt spays fɔ kɔntinyu fɔ de rawnd.
Translet ɔ kɔstɔmayz di string dɛn wit SCSS
Dɛn kin yuz di :lang()pseudo-klas fɔ alaw fɔ translet di “Browse” tɛks insay ɔda langwej dɛn. Ɔvarayd ɔ ad ɛntri dɛn to di $custom-file-textSass vɛriɔbul wit di rilevɛns langwej tɛg ɛn lokaliz string dɛn. Yu kin kɔstɔmayt di Inglish string dɛn di sem we. Fɔ ɛgzampul, na dis na aw pɔsin kin ad Spanish transleshɔn (Spanish in langwej kɔd na es):
Na dis na lang(es)in akshɔn pan di kɔstɔm fayl input fɔ wan Spanish transleshɔn:
Yu go nid fɔ sɛt di langwej fɔ yu dɔkyumɛnt (ɔ di sabtri fɔ am) kɔrɛkt wan fɔ mek dɛn sho di kɔrɛkt tɛks. Dis kin bi yuz di langatribyut we de na di <html>ɛlimɛnt ɔ di Content-LanguageHTTP hεda , wit ɔda we dɛn.
Fɔ translet ɔ kɔstɔmayt di string dɛn wit HTML
Bootstrap de gi bak wan we fɔ translet di “Browse” tɛks insay HTML wit di data-browseatribyut we dɛn kin ad to di kɔstɔm input lɛbl (ɛgzampul insay Dɔch):