Misaliw ni baarakɛcogo ɲɛfɔli sɛbɛnw kɔlɔsili cogoyaw kan, labɛncogo suganditaw, ani ladamu yɔrɔw walasa ka sɛbɛn suguya caman dilan.
Kuma bɛɛ lajɛlen
Bootstrap ka foroko kunkankow bɛ bonya an ka Rebooted foroko cogoyaw kan ni kalanw ye. Baara kɛ ni o kalanw ye walasa ka i yɛrɛ sugandi u ka jiralanw kɔnɔ minnu bɛ kɛ ka kɛɲɛ ni u yɛrɛ sago ye walasa ka ɲɛfɔli kɛ cogo kelen na navigatɛriw ni minɛnw kɔnɔ.
Aw ye aw jija ka baara kɛ ni fɛn bɛnnen typeye donnakow bɛɛ kan (misali la, emailimayili ladɛrɛsi walima numberjatebɔ kunnafoniw kama) walasa ka nafa sɔrɔ donnakow kunnafoni kuraw la i n’a fɔ imɛri sɛgɛsɛgɛli, nimɔrɔ sugandili, ani fɛn wɛrɛw.
Nin ye misali teliya ye walasa ka Bootstrap ka foroko cogoyaw jira. Aw bɛ to ka kalan kɛ walasa ka sɛbɛnw sɔrɔ kalan wajibiyalenw kan, sɛbɛnw labɛncogo ani fɛn wɛrɛw.
Foroko kunkankow
Sɛbɛnni cogoya kɔrɔsibagaw—i n’a fɔ <input>s, <select>s ani <textarea>s—u bɛ cogoya ni .form-controlkalasi ye. O la, cogoyaw bɛ yen minnu bɛ kɛ ka ɲɛsin fɛn bɛɛ yecogo ma, sinsin cogoya, bonya ani fɛn wɛrɛw.
Aw ye aw jija ka an ka ladamu sɛbɛnw sɛgɛsɛgɛ walasa ka style <select>s wɛrɛw sɔrɔ.
Walasa ka filen dontaw sɔrɔ, i ka .form-controlfor .form-control-file.
Sizing (Sizing) kɛ
Aw bɛ sanfɛlanw sigi ni kalanw ye i n' a fɔ .form-control-lgani .form-control-sm.
Kalan dɔrɔn
A bɛ readonlyboolean attribut (boli) fara donnafɛn dɔ kan walasa ka donnafɛn nafa caman caman cili bali. Kalan dɔrɔn dontaw bɛ ye ka nɔgɔya (i n’a fɔ donnakow balilenw), nka u bɛ taamasiyɛn jɔnjɔn mara.
Sɛbɛn gansan kalanni dɔrɔn
N’i b’a fɛ ka <input readonly>fɛn dɔw sɔrɔ i ka foroko kɔnɔ minnu bɛ kɛ cogo la i n’a fɔ sɛbɛn gansan, i ka baara kɛ ni .form-control-plaintextkalasi ye walasa ka foroko foroko cogoya dafalen bɔ yen ani ka margin ni padding ɲuman mara.
Range Inputs (Dɔnniyaw).
Set horizontalement scrollable range inputs ni .form-control-range.
Jateminɛ kɛyɔrɔw ani arajow
sɛgɛsɛgɛlikɛyɔrɔw ni arajow daminɛtaw bɛ ɲɛ ni dɛmɛ ye .form-check, kalan kelen donnadon suguya fila bɛɛ la min bɛ u ka HTML fɛnw labɛncogo n' u kɛcogo ɲɛ Jateminɛ kɛyɔrɔw ye sugandili kelen walima caman sugandili ye lisi dɔ kɔnɔ, ka sɔrɔ arajow ye sugandili kelen sugandi caman cɛma.
Jateminɛkɛyɔrɔw ni arajo minnu bɛ se ka baara kɛ, olu bɛ dɛmɛ. Attribut disabledbɛna kulɛri nɔgɔman dɔ kɛ walasa ka dɛmɛ don ka donnakow cogoya jira.
Jateminɛ kɛsu ni arajo butɔni bɛ HTML-based form validation dɛmɛ ani ka labeli surunw di, minnu bɛ se ka sɔrɔ. O cogo la, an ka <input>s ni <label>s ye balimakɛ-fɛnw ye k’a sɔrɔ an tɛ kelen ye min <input>kɔnɔ a <label>. nin ye kumasen ye dɔɔnin i n' a fɔ i ka kan ka ɲɛfɔli idni forjogo jira walasa ka ni <input>ni jɛ <label>.
Default (dafalen) .
Ka da a kan, jatebɔlanw ni arajo hakɛ o hakɛ min ye balimakɛw ye teliya la, olu bɛna bila ɲɔgɔn kan cogo bɛnnen na ni .form-check.
Inline kɔnɔ
kuluw lajɛyɔrɔw walima arajow kulu kelen kan jirisunba kelen kan ni dɔ farali .form-check-inlineye fɛn o fɛn .form-checkkan .
Ni labeliw tɛ
Fàrala .position-staticdontaw kan minnu kɔnɔ .form-checkminnu tɛ ni labeli sɛbɛn si ye. Aw ye aw hakili to a la hali bi ka labeli sugu dɔ di dɛmɛni fɛɛrɛw ma (misali la, ka baara kɛ ni aria-label).
Labɛn cogo
Komin Bootstrap bɛ baara Kɛ display: blockani width: 100%an ka forobaciyɛn-kɔlɔsili-minɛnw bɛɛ lajɛlen na, foroko-sɛbɛnw bɛna ɲɔgɔn Sɔrɔ ka Kɛɲɛ ni jɔlen ye. Kalanso wɛrɛw bɛ se ka kɛ walasa ka o labɛncogo caman ɲɔgɔnna kɛ ka kɛɲɛ ni sɛbɛn kelen-kelen bɛɛ ye.
Aw bɛ kuluw sigi sen kan
Kalanso .form-groupye fɛɛrɛ nɔgɔman ye min bɛ se ka sigicogo dɔw fara sɛbɛnw kan. A bɛ kalan dɔ di min bɛ se ka wuli ka bɔ a nɔ na, min bɛ dusu don mɔgɔw kɔnɔ u ka kuluw kɛ ɲɔgɔn fɛ cogo bɛnnen na, ka kunnafoniw di, ka dɛmɛ sɛbɛn minnu bɛ se ka sugandi, ani ka sɛbɛnw tiɲɛni cikanw ci. By default it only applies margin-bottom, nka a bɛ cogoya wɛrɛw ta ka don .form-inlinei n’a fɔ a mago bɛ cogo min na. Baara kɛ n’a ye ni <fieldset>s, <div>s, walima fɛn wɛrɛw ye minnu bɛ se ka fɔ.
Formulaire grid
Foroko gɛlɛnw bɛ se ka jɔ ni an ka grid classes ye. Baara kɛ ni ninnu ye sɛbɛnw labɛncogo kama minnu bɛ kulu caman wajibiya, bonya caman wɛrɛw, ani ɲɔgɔndan sugandicogo wɛrɛw.
Foroko row
Aw bɛ se fana ka swap .rowfor .form-row, an ka standard grid row caman caman ɲɔgɔnna min bɛ kolon gutters defaults override for tighter and compact layouts.
Layidu minnu ka gɛlɛn kosɛbɛ, olu fana bɛ se ka dilan ni grid system ye.
Foro horizontal (fɔcogo tilennen).
Aw bɛ foroko tilennenw da ni jatebɔlan ye ni .rowkalasi farali ye kuluw dilancogo kan ani ka baara kɛ ni .col-*-*kalasiw ye walasa k’aw ka labeliw ni kɔrɔsiliw bonya jira. Aw ye aw jija ka dɔ fara .col-form-labelaw ka <label>s kan fana walasa u ka kɛ vertically centered ni u ni u ni ɲɔgɔn cɛ formulaire controls ye.
Tuma dɔw la, i bɛ se ka baara kɛ ni margin walima padding utilities ye walasa ka o alignment dafalen dilan i mago bɛ min na. Misali la, an ye padding-topan ka arajo dontaw labeli min bɛ ɲɔgɔn kan, o bɔ yen walasa ka sɛbɛnni basigilenw labɛn ka ɲɛ.
Formulaire horizontale label sizing
Aw ye aw jija ka baara kɛ ni .col-form-label-smwalima .col-form-label-lgka aw ka <label>s walima <legend>s kɛ walasa ka tugu a bonya la ka ɲɛ .form-control-lgani .form-control-sm.
Kolonw bonya
I n’a fɔ a jiralen bɛ cogo min na misali tɛmɛnenw na, an ka jatebɔcogo b’a to i bɛ se ka .cols hakɛ o hakɛ bila a .rowwalima .form-row. U bɛna bonya sɔrɔlenw tila u ni ɲɔgɔn cɛ cogo kelen na. Aw bɛ se fana k’aw ka kuluw kulu fitinin dɔ ta walasa ka yɔrɔ caman walima yɔrɔ fitinin ta, k’a sɔrɔ .cols tɔw bɛ tɔw tila ɲɔgɔn na, ni kuluw kalasi kɛrɛnkɛrɛnnenw ye i n’a fɔ .col-7.
Oto-sizing (yɛrɛ-sɛgɛsɛgɛli).
Misali min bɛ duguma o bɛ baara Kɛ ni flexbox nafamafɛn ye walasa ka kɔnɔkow cɛmancɛ jɔlen na ani ka fɛn caman Changer .colka Kɛ .col-autowalasa i ka kuluw bɛ yɔrɔ caman dɔrɔn Ta i n’a fɔ u mago bɛ cogo min na. Ni an y’a fɔ cogo wɛrɛ la, kulu bɛ a yɛrɛ bonya ka da a kɔnɔkow kan.
O kɔfɛ, aw bɛ se k’o ɲagami kokura siɲɛ kelen ni hakɛ kɛrɛnkɛrɛnnen koloma kalanw ye.
Baara kɛ ni .form-inlinekalan ye walasa ka labeliw, foroko kunkankow ani butɔni dɔw jira ɲɔgɔn kɔ jirisun kelen kan. Formulaire controls inline forms kɔnɔ, olu bɛ danfara dɔɔnin ka bɔ u cogoya kɔrɔw la.
Kontrɔliw ye display: flex, ka HTML yɔrɔ finman o yɔrɔ finman bɛɛ Dabɔ ani k’a To i bɛ se ka alignment control Di ni spacing ani flexbox utilities ye.
Kontrɔli ni donna kuluw bɛ sɔrɔ width: autoka Bootstrap default wuli width: 100%.
Kontrɔliw bɛ jira dɔrɔn layini kɔnɔ filɛlikɛyɔrɔw la minnu bonya ye 576px ye a dɔgɔyalenba la walasa ka jate kɛ filɛlikɛyɔrɔ fitininw na telefɔni selilɛriw kan.
Aw bɛ se ka sɛbɛnfura kelen-kelen bɛɛ kunkankow bonya n’u labɛncogo ɲɛnabɔ ni bolo ye ni yɔrɔjan nafamafɛnw ye (i n’a fɔ a jiralen bɛ cogo min na jukɔrɔ). A laban na, aw ye aw jija ka a don tuma bɛɛ <label>ni sɛbɛnfura kelen-kelen bɛɛ kunnafoni ye, hali n’aw mago bɛ a la k’a dogo mɔgɔ minnu tɛ ekran kalanbagaw ye ni .sr-only.
Custom form controls ani selects fana bɛ dɛmɛ.
Fɛn wɛrɛw minnu bɛ se ka kɛ ka tɛmɛ labeli dogolenw kan
Dɛmɛn fɛɛrɛw i n’a fɔ ɛkran kalanbagaw bɛna gɛlɛya sɔrɔ i ka sɛbɛnw na ni i ma sɛbɛn dɔ don donta bɛɛ la. Nin inline sɛbɛnw kama, aw bɛ se ka labeliw dogo ni .sr-onlykalan ye. Fɛɛrɛ wɛrɛw bɛ yen minnu bɛ se ka kɛ walasa ka taamasiyɛn di dɛmɛ fɛɛrɛw ma, i n’a fɔ aria-label, aria-labelledbywalima fɛn titlemin bɛ kɛ ka fɛn dɔ jira. Ni ninnu si tɛ yen, dɛmɛ fɛɛrɛw bɛ se ka baara kɛ ni o placeholderjogo ye, ni u bɛ yen, nka aw k’a kɔlɔsi ko baara kɛli ye placeholderka kɛ taamasiyɛn kɛcogo wɛrɛw nɔnabila ye, o tɛ ladilikan ye.
Dɛmɛ sɛbɛn
Block-level dɛmɛ sɛbɛnni minnu bɛ sɛbɛnw kɔnɔ, olu bɛ se ka dabɔ ni .form-text(a tun bɛ fɔ fɔlɔ i n’a fɔ .help-blockv3 kɔnɔ). Inline dɛmɛ sɛbɛnni bɛ se ka waleya cogo la min bɛ se ka wuli ni inline HTML element suguya o suguya ye ani utility classes i n' a fɔ .text-muted.
Dɛmɛ sɛbɛn ni sɛbɛnfura kunkankow fara ɲɔgɔn kan
Dɛmɛ sɛbɛn ka kan ka jɛ k’a jɛya ni sɛbɛnfura kunkanko ye a bɛ tali kɛ ni fɛn ye min bɛ baara kɛ ni o fɛn aria-describedbyye. O bɛna a to dɛmɛ fɛɛrɛw — i n’a fɔ ɛkran kalanbagaw — bɛna o dɛmɛ sɛbɛn in laseli kɛ ni baarakɛla ye a sinsin walima ni a donna kunnafoni na.
Dɛmɛ sɛbɛn minnu bɛ dontaw jukɔrɔ, olu bɛ se ka kɛ cogoya la ni .form-text. Nin kalan in kɔnɔ, display: blocksanfɛ-dakun dɔw bɛ yen ani ka fara a kan walasa ka yɔrɔjan nɔgɔya ka bɔ donnakow la sanfɛ.
I ka tɔgɔlasɛbɛn janya ka kan ka kɛ taamasiyɛn 8-20 ye, lɛtɛrɛw ni nimɔrɔw ka kan ka sɔrɔ a kɔnɔ, wa a man kan ka kɛ ni yɔrɔw ye, sɛbɛnni kɛrɛnkɛrɛnnenw, walima emojiw.
Inline sɛbɛnni bɛ Se ka baara Kɛ ni HTML fɛn o fɛn ye min bɛ Kɛ inline kɔnɔ (a kɛra <small>, <span>, walima fɛn wɛrɛ ye) ni foyi tɛ yen ni nafalan-klasi tɛ.
Seko ni dɔnko sɛbɛnw
A bɛ disabledboolean attribut (boli) fara donnafɛn dɔ kan walasa ka baarakɛlaw ka jɛɲɔgɔnyaw bali ani k’a kɛ i n’a fɔ a ka nɔgɔn.
A ka disabledfɛntigiya fara a kan <fieldset>walasa ka kunnafoni bɛɛ bali a kɔnɔ.
Kɔlɔsili ni ankɔriw ye
O cogo la, navigatɔrɔw bɛna foroko kɔrɔw bɛɛ minɛ ( <input>, <select>ani <button>fɛnw) minnu bɛ a kɔnɔ <fieldset disabled>i n’a fɔ u ma baara kɛ, ka klaviyeti ni sosɛti bɛɛ ka jɛɲɔgɔnya bali u kan. Nka, ni i ka foroko fana bɛ ni <a ... class="btn btn-*">fɛnw ye, olu bɛna di dɔrɔn cogoya dɔ ma min ye pointer-events: none. I n’a fɔ a fɔra cogo min na dakun na min bɛ kuma butɔni cogoya balilen kan (ani kɛrɛnkɛrɛnnenya la dakun fitinin min bɛ ankɔri fɛnw kan), nin CSS nafolo in ma labɛn fɔlɔ wa a ma dɛmɛ bɛrɛbɛrɛ Internet Explorer 10 kɔnɔ, wa a tɛna klaviyeti baarakɛlaw bali ka kɛ se ka sinsin walima ka baara kɛ ni nin jɛgɛnsira ninnu ye. O la sa, walisa i ka se ka i yɛrɛ tanga, baara kɛ ni JavaScript ye min bɛ kɛ ka kɛɲɛ ni i yɛrɛ sago ye walisa k’o ɲɔgɔnna ladɛrɛsiw bali.
Cross-browser ka baarakɛcogo ɲuman
Hali ni Bootstrap bɛna o cogoyaw waleya navigatɔrɔw bɛɛ la, Internet Explorer 11 ani a duguma tɛ fɛn in dɛmɛ kosɛbɛ a disabledkan <fieldset>. Baara kɛ ni JavaScript ye min bɛ kɛ ka kɛɲɛ ni i yɛrɛ sago ye walasa ka forow labɛncogo bali o navigatɛriw kɔnɔ.
Validation (Sɔrɔli).
Aw ye hakilina nafamaw di aw ka baarakɛlaw ma minnu bɛ se ka wale kɛ ni HTML5 sɛbɛnfura tiɲɛni ye– min bɛ sɔrɔ an ka navigatɔrɔw bɛɛ kɔnɔ minnu bɛ dɛmɛ sɔrɔ . Sugandili kɛ navigatɛri default validation feedback kɔnɔ, walima ka cikanw waleya ni an ka kalansenw ye minnu bɛ don a kɔnɔ ani JavaScript daminɛ.
An bɛ ladilikan di sisan ka baara kɛ ni sɛgɛsɛgɛli kɛcogoyaw ye minnu bɛ kɛ ka kɛɲɛ ni mɔgɔw sago ye, bawo native navigateur default validation messages tɛ to ka jira dɛmɛnan fɛɛrɛw la navigatɔrɔw bɛɛ kɔnɔ (kɛrɛnkɛrɛnnenya la, Chrome min bɛ tabali kan ani telefɔni selilɛri kan).
A bɛ baara kɛ cogo min na
Formulaire validation bɛ baara kɛ cogo min na ni Bootstrap ye, o filɛ nin ye:
HTML foroko sɛgɛsɛgɛli bɛ Kɛ CSS ka pseudo-classes fila fɛ, :invalidani :valid. A bɛ tali kɛ <input>, <select>, ani <textarea>fɛnw na.
Bootstrap bɛ scopes the :invalidand :validstyles to parent .was-validatedclass, a ka c’a la a bɛ kɛ ka <form>. N’o tɛ, foro wajibiyalen o foro wajibiyalen tɛ ni nafa tɛ, o bɛ jira ko a tɛ baara kɛ ɲɛ doni na. O cogo la, i bɛ se k’a sugandi waati min na i bɛna u baara (a ka c’a la, sɛbɛn cilen kɔfɛ).
Walasa ka sɛbɛn in cogoya lasegin (misali la, ni sɛbɛn cicogo dinamiki ye ni AJAX ye), i ka .was-validatedkalasi bɔ a la <form>tuguni cilen kɔfɛ.
I n’a fɔ fallback, .is-invalidani .is-validkalasiw bɛ se ka baara kɛ ni pseudo-classes nɔ na ka ɲɛsin server fan fɛ validation ma . U tɛ .was-validatedbangebagaw ka kalan wajibiya.
K’a sababu Kɛ gɛlɛyaw ye CSS baaracogo la, an tɛ Se (sisan) ka cogoyaw Kɛ a la <label>min bɛ Nà foroba-kɔlɔsili ɲɛfɛ DOM kɔnɔ ni JavaScript ladamulen dɛmɛ tɛ.
Bi navigatɔrɔw bɛɛ bɛ constraint validation API dɛmɛ , o ye JavaScript fɛɛrɛw ye minnu bɛ kɛ ka forobaciyɛn kunkankow sɛmɛntiya.
Jaabi cikanw bɛ se ka baara kɛ ni navigatɔrɔn ka defaults (navigatɛri kelen-kelen bɛɛ ta tɛ kelen ye, wa u tɛ se ka kɛ cogo la CSS fɛ) walima an ka jaabiw cogoya ladamulenw ni HTML ni CSS wɛrɛw ye.
Aw bɛ se ka ladamu cikanw di ni setCustomValidityJavaScript ye.
O hakili la, i ka nin demow lajɛ an ka ladamu sɛbɛnw tiɲɛni cogoyaw la, sèrwɛri fan fɛ kalan minnu bɛ se ka sugandi, ani navigatɔrɔw ka defaults.
Laadalata cogoyaw
Ni aw b’a fɛ ka Bootstrap foroko dafalen cikanw sɔrɔ, aw ka kan ka novalidateboolean fɛnsɛbɛnni fara aw ka <form>. O bɛ browser default feedback baarakɛminɛnw bali, nka o bɛɛ n’a ta, a bɛ se ka kɛ sababu ye ka formulaire validation APIw sɔrɔ JavaScript kɔnɔ. A ɲini ka sɛbɛn in di min bɛ duguma; an ka JavaScript bɛna submit button minɛ ka hakilinaw lase i ma. Ni i b’a ɲini ka ci, i bɛna a ye ko :invalidani :validcogoyaw bɛ tali kɛ i ka foroko kunkankow la.
Ladamuni kɛcogoyaw bɛ ladamu kulɛriw, dancɛw, sinsincogo cogoyaw ani kɔkanna taamasiyɛnw kɛ walasa ka hakilinaw lase mɔgɔw ma ka ɲɛ. Background icons for <select>s bɛ sɔrɔ ni .custom-select, dɔrɔn de ye , wa .form-control.
Navigatɛri ka defaults
Aw t’a fɛ ka ladamu tiɲɛni jaabi cikanw sɔrɔ walima ka JavaScript sɛbɛn walasa ka foroko kɛcogo caman Changer wa? O bɛɛ ka ɲi, i bɛ se ka baara kɛ ni browser defaults ye. A ɲini ka sɛbɛn in ci min bɛ duguma. Ka kɛɲɛ n’i ka navigatɔrɔ ni OS ye, i bɛna hakilinaw dicogo wɛrɛ ye dɔɔnin.
Hali n’o hakilinaw cogoyaw tɛ se ka cogoya kɛ ni CSS ye, i bɛ se ka jaabiw sɛbɛncogo ladilan hali bi JavaScript fɛ.
Server fan fɛ
An b’a ɲini aw fɛ aw ka baara kɛ ni kiliyan fan fɛ sɛgɛsɛgɛli ye, nka ni aw mago bɛ baarakɛla fan fɛ sɛgɛsɛgɛli la, aw bɛ se ka foroko forow jira minnu tɛ tiɲɛ ye ani minnu bɛ se ka kɛ ni .is-invalidani .is-valid. A kɔlɔsi ko .invalid-feedbackfana bɛ dɛmɛ ni nin kalan ninnu ye.
Fɛn minnu bɛ dɛmɛ
Validation styles bɛ sɔrɔ nin formulaire controles ni components ninnu na:
<input>s ni <textarea>s ni .form-control(ka se kelen .form-controlma donna kuluw kɔnɔ) .
<select>s ni .form-controlwalima.custom-select
.form-checks
.custom-checkboxs ni .custom-radios
.custom-file
Baarakɛminɛnw ladilikanw
Ni i ka foroko labɛncogo b’a to, i bɛ se ka kalanw falen-falen .{valid|invalid}-feedbackkalanw kama .{valid|invalid}-tooltipwalasa ka dantigɛli hakilinaw jira baarakɛminɛnw labɛncogo la. Aw ye aw jija ka bangebaga dɔ position: relativesɔrɔ a kan baarakɛminɛnw bilali kama. Misali min bɛ duguma, an ka kulu kalanw bɛ nin sɔrɔ kaban, nka i ka porozɛ bɛ se ka kɛ sababu ye ka sigicogo wɛrɛ de wajibiya.
Ka kɛɲɛ ni mɔgɔw sago ye
Validation states bɛ se ka ladamu Sass fɛ ni $form-validation-stateskarti ye. A bɛ an ka _variables.scssdosiye kɔnɔ, nin Sass karti in bɛ loop over ka default valid/ invalidvalidation states (dafalen / validation states) lawuli. Karta min bɛ a kɔnɔ, o bɛ sɔrɔ a kɔnɔ walasa ka jamana kelen-kelen bɛɛ ka kulɛri ni a taamasiyɛnw labɛn ka kɛɲɛ ni u yɛrɛ sago ye. Hali ni jamana wɛrɛw tɛ dɛmɛ sɔrɔ navigatɛriw fɛ, minnu bɛ baara kɛ ni ladamu cogoyaw ye, olu bɛ se ka forobaciyɛn jaabi gɛlɛnw fara nɔgɔya la.
Aw k’a dɔn ko an tɛ ladilikan di ka nin nafaw ladilan k’a sɔrɔ an ma form-validation-statemixin fana sɛmɛntiya.
Laadalata sɛbɛnw
Walasa ka fɛn caman wɛrɛw sɔrɔ ani ka navigatɔrɔw ka ɲɔgɔn sɔrɔ cogo min na, baara kɛ ni an ka foroko kɔnɔfɛnw ye minnu bɛ kɛ ka kɛɲɛ ni mɔgɔw sago ye pewu walasa ka navigatɔrɔw ka fɛnw bila u nɔ na. U jɔlen bɛ kɔrɔko ni sɔrɔli taamasiyɛnw sanfɛ, o la u ye fɛn sabatilenw ye minnu bɛ se ka kɛ foroko kɔrɔsili fɔlɔw bɛɛ nɔnabila ye.
Jateminɛ kɛyɔrɔw ani arajow
Checkbox kelen-kelen bɛɛ ani arajo <input>ani <label>pari bɛ siri a la <div>walasa k’an ka custom control dilan. Jatebla siratigɛ la, nin ye an ka default kɛcogo kelen ye .form-check.
An bɛ baara kɛ ni balimakɛ sugandilan ( ~) ye an ka <input>jamanaw bɛɛ kama—i n’a fɔ :checked—walasa ka an ka ladamu sɛbɛn jiralan cogoya ka ɲɛ. Ni an farala .custom-control-labelkalan kan, an bɛ se fana ka sɛbɛnni kɛcogo kɛ fɛn kelen-kelen bɛɛ la ka da <input>'s cogoya kan.
An bɛ default dogo <input>ni opacityani ka baara kɛ ni the ye .custom-control-labelwalasa ka ladamu sɛbɛn jiralan kura jɔ a nɔ na ni ::beforeani ::after. A fɔ man di nka an tɛ se ka ladamu dɔ jɔ ka bɔ dɔrɔn <input>bawo CSS'w contenttɛ baara kɛ o element kan.
Jamana minnu sɛgɛsɛgɛra, an bɛ baara kɛ ni base64 SVG taamasiyɛnw ye minnu bɛ don Open Iconic kɔnɔ. O bɛ kunnafoni ɲuman Di an ma cogoya ni jɔyɔrɔko la navigatɔrɔw ni minɛnw kɔnɔ.
Jateminɛw kɛyɔrɔw
Ladamuni-sɛbɛnw fana bɛ Se ka baara Kɛ ni :indeterminatepseudo class ye ni u bɛ Se ka Kɛ ni bolo ye JavaScript fɛ (HTML fɛn si tɛ yen min bɛ Se k’a Jira).
N'i bɛ baara Kɛ ni jQuery ye, nin ɲɔgɔnna dɔ ka kan ka Bɔ:
Arajow
Inline kɔnɔ
A jɔ la
Labɛnw ni arajow fana bɛ se ka bali. A bɛ disabledboolean fɛnsɛbɛn fara a kan <input>ani ladamu jiralan ni labeli ɲɛfɔli bɛna kɛ a yɛrɛma cogoya la.
Switches (switchw).
Switch dɔ bɛ ni markup ye custom checkbox nka a bɛ baara kɛ ni .custom-switchclass ye walasa ka toggle switch dɔ jira. Switches fana bɛ disabledattribut (fɛn) in dɛmɛ.
Menu sugandi
Meniw ladamulenw <select>mago bɛ ladamu kalan dɔrɔn de la, .custom-selectwalasa ka ladamu cogoyaw daminɛ. Laadalata cogoyaw dan ye <select>'s yecogo fɔlɔ ye wa u tɛ se ka s ladilan <option>k'a sababu kɛ navigatɛri dantigɛliw ye.
I bɛ se fana ka sugandili kɛ ladamu sugandili misɛnninw ni belebelebaw la walasa u ka bɛn an ka sɛbɛnniw dontaw ma minnu bonya ye kelen ye.
O multiplefɛn in fana bɛ Dɛmɛ:
I n’a fɔ a bɛ cogo min na ni a ka sizejogo ye:
Labɛnko ɲuman
Aw bɛ ladamukow dabɔ <input type="range">ni .custom-range. Track (kɔfɛ) ani thumb (nafa) fila bɛɛ cogoya bɛ cogo kelen na navigatɛriw kɔnɔ. Komin IE ni Firefox dɔrɔn de bɛ dɛmɛ Dòn u ka fɔlisen “falen” na ka Bɔ bolokɔnincinin kinin fɛ walima kinin fɛ k’a Kɛ fɛɛrɛ ye walasa ka ɲɛtaa jira ɲɛ na, an t’a Dɛmɛ sisan.
Range inputs bɛ ni implicit values ye minani max— 0ani 100, o cogo la. Aw bɛ se ka nafa kuraw jira minnu bɛ baara kɛ ni minani maxfɛnw ye.
Ka da a kan, range inputs “snap” ka kɛ integer values ye. Walasa ka nin fɛn caman Changer, aw bɛ se ka stepnafa dɔ jira. Misali min bɛ duguma, an bɛ taabolo hakɛ caya siɲɛ fila ni baara kɛli ye ni step="0.5".
Fiyew lajɛcogo
Plugin min bɛ Lakodɔn walasa ka custom file input ɲɛnamaya: bs-custom-file-input , o de ye an bɛ baara Kɛ ni min ye sisan yan an ka docs kɔnɔ.
Filen doncogo ye gnarly ye bunch la wa a bɛ JavaScript wɛrɛw de wajibiya n'i b'a fɛ k'u jɛgɛn ni functional Choose file... ani file name text sugandilen ye.
An bɛ filen default dogo <input>via opacityani o nɔ na style the <label>. Butɔn bɛ sɔrɔ ka jɔ ni ::after. A laban na, an b’a Jira ko a widthni heighton the <input>for proper spacing for surrounding content.
Sɛrɛw bamanankan na walima k’u labɛn ni SCSS ye
Pseudo - :lang()class bɛ Kɛ walasa ka sira Di “Browse” sɛbɛnni bamanankan na kan wɛrɛw la. Sass bεε bε bεnkanw bεε bεε bεε bε Se ka bεnkanw bεε Kε walima ka u Fàra u kan ni kan taamaʃyɛn$custom-file-text min bɛ tali Kɛ o la ani sigida ka sɛrɛw. Angilɛkan sɛrɛw bɛ se ka ladilan o cogo kelen na. Misali la, mɔgɔ bɛ se ka Ɛsipaɲɔlikan bamanankan baarakɛcogo dɔ fara a kan cogo min na, o filɛ nin ye (Esipaɲɔlikan kanko ye ):es
Nin ye lang(es)wale ye ladamu filen doncogo kan Ɛsipaɲɔlikan bamanankan na:
I bɛna a ɲini ka i ka sɛbɛn (walima a jirisun fitinin) kan sigi ka ɲɛ walasa sɛbɛnni ɲuman ka jira. O bɛ Se ka Kɛ ni fɛnɲɛnɛma langye min bɛ <html>element kan walima Content-LanguageHTTP header , fɛɛrɛ wɛrɛw cɛma.
Sɛbɛnw bamanankan na walima k’u ladilan ni HTML ye
Bootstrap fana bɛ fɛɛrɛ Di “Browse” sɛbɛnni bamanankan na HTML la ni fɛn data-browseye min bɛ Se ka Fàra sɛbɛnni-sɛbɛnni ladamulen kan (misali la Ɔsitaralikan na):