Source

Siffofin

Misalai da jagororin amfani don salon sarrafa nau'i, zaɓuɓɓukan shimfidawa, da abubuwan haɗin kai na al'ada don ƙirƙirar nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan nau'ikan abubuwan da aka tsara za a iya yin zaɓin zaɓi.

Dubawa

Gudanar da fom ɗin Bootstrap yana faɗaɗa kan salon fasalin mu da aka sake yi tare da azuzuwan. Yi amfani da waɗannan azuzuwan don ficewa cikin keɓancewar nunin su don ƙarin daidaiton ma'ana a cikin masu bincike da na'urori.

Tabbatar amfani da typesifa mai dacewa akan duk abubuwan shigarwa (misali, emaildon adireshin imel ko numberdon bayanin lamba) don cin gajiyar sabbin abubuwan sarrafawa kamar tabbatarwa imel, zaɓin lamba, da ƙari.

Anan ga misali mai sauri don nuna salon sigar Bootstrap. Ci gaba da karantawa don takaddun azuzuwan da ake buƙata, shimfidar tsari, da ƙari.

Ba za mu taɓa raba imel ɗinku da wani ba.
<form>
  <div class="form-group">
    <label for="exampleInputEmail1">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
    <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1">Password</label>
    <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
  </div>
  <div class="form-check">
    <input type="checkbox" class="form-check-input" id="exampleCheck1">
    <label class="form-check-label" for="exampleCheck1">Check me out</label>
  </div>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>

Gudanar da tsari

Sarrafa nau'ikan rubutu-kamar <input>s, <select>s, da <textarea>s-an tsara su tare da .form-controlajin. An haɗa da salo don bayyanar gaba ɗaya, yanayin mayar da hankali, girman girman, da ƙari.

Tabbatar bincika siffofin mu na al'ada don ƙarin salon <select>s.

<form>
  <div class="form-group">
    <label for="exampleFormControlInput1">Email address</label>
    <input type="email" class="form-control" id="exampleFormControlInput1" placeholder="[email protected]">
  </div>
  <div class="form-group">
    <label for="exampleFormControlSelect1">Example select</label>
    <select class="form-control" id="exampleFormControlSelect1">
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
      <option>5</option>
    </select>
  </div>
  <div class="form-group">
    <label for="exampleFormControlSelect2">Example multiple select</label>
    <select multiple class="form-control" id="exampleFormControlSelect2">
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
      <option>5</option>
    </select>
  </div>
  <div class="form-group">
    <label for="exampleFormControlTextarea1">Example textarea</label>
    <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
  </div>
</form>

Don shigar da fayil, musanya .form-controldon .form-control-file.

<form>
  <div class="form-group">
    <label for="exampleFormControlFile1">Example file input</label>
    <input type="file" class="form-control-file" id="exampleFormControlFile1">
  </div>
</form>

Girman girma

Saita tsayi ta amfani da azuzuwan kamar .form-control-lgda .form-control-sm.

<input class="form-control form-control-lg" type="text" placeholder=".form-control-lg">
<input class="form-control" type="text" placeholder="Default input">
<input class="form-control form-control-sm" type="text" placeholder=".form-control-sm">
<select class="form-control form-control-lg">
  <option>Large select</option>
</select>
<select class="form-control">
  <option>Default select</option>
</select>
<select class="form-control form-control-sm">
  <option>Small select</option>
</select>

Karatu kawai

Ƙara readonlysifa ta boolean akan shigarwa don hana gyara ƙimar shigarwar. Abubuwan da ake karantawa kawai suna bayyana masu sauƙi (kamar abubuwan da aka kashe), amma suna riƙe daidaitaccen siginan kwamfuta.

<input class="form-control" type="text" placeholder="Readonly input here…" readonly>

Karatun rubutu kawai

Idan kana son samun <input readonly>abubuwa a cikin nau'in fom ɗinka da aka tsara su azaman rubutu na fili, yi amfani da .form-control-plaintextajin don cire salon sigar filin da aka saba da kuma adana daidaitaccen gefe da padding.

<form>
  <div class="form-group row">
    <label for="staticEmail" class="col-sm-2 col-form-label">Email</label>
    <div class="col-sm-10">
      <input type="text" readonly class="form-control-plaintext" id="staticEmail" value="[email protected]">
    </div>
  </div>
  <div class="form-group row">
    <label for="inputPassword" class="col-sm-2 col-form-label">Password</label>
    <div class="col-sm-10">
      <input type="password" class="form-control" id="inputPassword" placeholder="Password">
    </div>
  </div>
</form>
<form class="form-inline">
  <div class="form-group mb-2">
    <label for="staticEmail2" class="sr-only">Email</label>
    <input type="text" readonly class="form-control-plaintext" id="staticEmail2" value="[email protected]">
  </div>
  <div class="form-group mx-sm-3 mb-2">
    <label for="inputPassword2" class="sr-only">Password</label>
    <input type="password" class="form-control" id="inputPassword2" placeholder="Password">
  </div>
  <button type="submit" class="btn btn-primary mb-2">Confirm identity</button>
</form>

Akwatunan rajista da rediyo

Akwatunan rajistan shiga da rediyo an inganta su tare da taimakon .form-check, aji ɗaya don nau'ikan shigarwar guda biyu waɗanda ke inganta shimfidawa da halayen abubuwan HTML ɗin su . Akwatunan rajista don zaɓar ɗaya ko zaɓuɓɓuka da yawa a cikin jeri, yayin da rediyo ke zaɓar zaɓi ɗaya daga mutane da yawa.

Ana goyan bayan akwatunan rajistan nakasassu da rediyo, amma don samar da not-allowedsiginan kwamfuta akan karkatar da iyaye <label>, kuna buƙatar ƙara disabledsifa zuwa .form-check-input. Siffar da aka kashe za ta yi amfani da launi mai sauƙi don taimakawa wajen nuna yanayin shigarwar.

Akwatunan rajistan shiga da amfani da rediyo an gina su don tallafawa ingantaccen tsari na tushen HTML da samar da takaitattun takubba masu isa. Don haka, <input>s ɗinmu da namu <label>abubuwa ne na 'yan uwan ​​juna sabanin na <input>cikin <label>. Wannan ɗan karin magana ne kamar yadda dole ne ka ƙayyade idda forsifofi don alaƙa <input>da <label>.

Tsohuwar (tarage)

Ta hanyar tsohuwa, kowane adadin akwatunan rajista da rediyo waɗanda ke da ɗan'uwan nan da nan za a lissafta su a tsaye da sarari da kyau tare da .form-check.

<div class="form-check">
  <input class="form-check-input" type="checkbox" value="" id="defaultCheck1">
  <label class="form-check-label" for="defaultCheck1">
    Default checkbox
  </label>
</div>
<div class="form-check">
  <input class="form-check-input" type="checkbox" value="" id="defaultCheck2" disabled>
  <label class="form-check-label" for="defaultCheck2">
    Disabled checkbox
  </label>
</div>
<div class="form-check">
  <input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="option1" checked>
  <label class="form-check-label" for="exampleRadios1">
    Default radio
  </label>
</div>
<div class="form-check">
  <input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios2" value="option2">
  <label class="form-check-label" for="exampleRadios2">
    Second default radio
  </label>
</div>
<div class="form-check disabled">
  <input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios3" value="option3" disabled>
  <label class="form-check-label" for="exampleRadios3">
    Disabled radio
  </label>
</div>

Layin layi

Akwatunan bincike na rukuni ko radiyo akan layi ɗaya a kwance ta ƙara .form-check-inlinezuwa kowane .form-check.

<div class="form-check form-check-inline">
  <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
  <label class="form-check-label" for="inlineCheckbox1">1</label>
</div>
<div class="form-check form-check-inline">
  <input class="form-check-input" type="checkbox" id="inlineCheckbox2" value="option2">
  <label class="form-check-label" for="inlineCheckbox2">2</label>
</div>
<div class="form-check form-check-inline">
  <input class="form-check-input" type="checkbox" id="inlineCheckbox3" value="option3" disabled>
  <label class="form-check-label" for="inlineCheckbox3">3 (disabled)</label>
</div>
<div class="form-check form-check-inline">
  <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
  <label class="form-check-label" for="inlineRadio1">1</label>
</div>
<div class="form-check form-check-inline">
  <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
  <label class="form-check-label" for="inlineRadio2">2</label>
</div>
<div class="form-check form-check-inline">
  <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3" disabled>
  <label class="form-check-label" for="inlineRadio3">3 (disabled)</label>
</div>

Ba tare da lakabi ba

Ƙara .position-staticzuwa abubuwan da ke ciki .form-checkwaɗanda ba su da kowane rubutun lakabi. Ka tuna har yanzu samar da wani nau'i na lakabin don fasahar taimako (misali, ta amfani da aria-label).

<div class="form-check">
  <input class="form-check-input position-static" type="checkbox" id="blankCheckbox" value="option1" aria-label="...">
</div>
<div class="form-check">
  <input class="form-check-input position-static" type="radio" name="blankRadio" id="blankRadio1" value="option1" aria-label="...">
</div>

Tsarin tsari

Tunda Bootstrap ya shafi display: blockkuma width: 100%kusan dukkan nau'ikan sarrafa nau'ikan mu, fom ɗin za su tari ta tsohuwa a tsaye. Ana iya amfani da ƙarin azuzuwan don bambanta wannan shimfidar wuri bisa kowane tsari.

Samar da ƙungiyoyi

Ajin .form-groupita ce hanya mafi sauƙi don ƙara wasu tsari zuwa siffofi. Yana ba da nau'i mai sassauƙa wanda ke ƙarfafa ƙungiyoyi masu dacewa na lakabi, sarrafawa, rubutun taimako na zaɓi, da samar da saƙon tabbatarwa. Ta hanyar tsoho yana aiki ne kawai margin-bottom, amma yana ɗaukar ƙarin salo a cikin .form-inlineyadda ake buƙata. Yi amfani da shi tare da <fieldset>s, <div>s, ko kusan kowane abu.

<form>
  <div class="form-group">
    <label for="formGroupExampleInput">Example label</label>
    <input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input">
  </div>
  <div class="form-group">
    <label for="formGroupExampleInput2">Another label</label>
    <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input">
  </div>
</form>

Tsarin tsari

Za a iya gina ƙarin hadaddun siffofin ta amfani da azuzuwan grid ɗin mu. Yi amfani da waɗannan don shimfidar tsari waɗanda ke buƙatar ginshiƙai da yawa, faɗin faɗin daban-daban, da ƙarin zaɓuɓɓukan jeri.

<form>
  <div class="row">
    <div class="col">
      <input type="text" class="form-control" placeholder="First name">
    </div>
    <div class="col">
      <input type="text" class="form-control" placeholder="Last name">
    </div>
  </div>
</form>

Tsarin layi

Hakanan kuna iya musanya .rowdon .form-row, bambancin daidaitaccen layin mu wanda ya ƙetare tsoffin ginshiƙan ginshiƙan don ƙarami kuma mafi ƙanƙanta shimfidu.

<form>
  <div class="form-row">
    <div class="col">
      <input type="text" class="form-control" placeholder="First name">
    </div>
    <div class="col">
      <input type="text" class="form-control" placeholder="Last name">
    </div>
  </div>
</form>

Hakanan za'a iya ƙirƙira ƙarin rikitattun shimfidu tare da tsarin grid.

<form>
  <div class="form-row">
    <div class="form-group col-md-6">
      <label for="inputEmail4">Email</label>
      <input type="email" class="form-control" id="inputEmail4" placeholder="Email">
    </div>
    <div class="form-group col-md-6">
      <label for="inputPassword4">Password</label>
      <input type="password" class="form-control" id="inputPassword4" placeholder="Password">
    </div>
  </div>
  <div class="form-group">
    <label for="inputAddress">Address</label>
    <input type="text" class="form-control" id="inputAddress" placeholder="1234 Main St">
  </div>
  <div class="form-group">
    <label for="inputAddress2">Address 2</label>
    <input type="text" class="form-control" id="inputAddress2" placeholder="Apartment, studio, or floor">
  </div>
  <div class="form-row">
    <div class="form-group col-md-6">
      <label for="inputCity">City</label>
      <input type="text" class="form-control" id="inputCity">
    </div>
    <div class="form-group col-md-4">
      <label for="inputState">State</label>
      <select id="inputState" class="form-control">
        <option selected>Choose...</option>
        <option>...</option>
      </select>
    </div>
    <div class="form-group col-md-2">
      <label for="inputZip">Zip</label>
      <input type="text" class="form-control" id="inputZip">
    </div>
  </div>
  <div class="form-group">
    <div class="form-check">
      <input class="form-check-input" type="checkbox" id="gridCheck">
      <label class="form-check-label" for="gridCheck">
        Check me out
      </label>
    </div>
  </div>
  <button type="submit" class="btn btn-primary">Sign in</button>
</form>

Siffar kwance

Ƙirƙirar sifofin kwance tare da grid ta ƙara .rowajin don samar da ƙungiyoyi da amfani da .col-*-*azuzuwan don ƙididdige faɗin alamunku da abubuwan sarrafawa. Tabbatar ƙara .col-form-labelzuwa <label>s ɗin ku don haka suna tsaye a tsaye tare da abubuwan sarrafa nau'ikan su.

A wasu lokuta, ƙila kuna buƙatar amfani da gefe ko abubuwan amfani don ƙirƙirar daidaitattun daidaiton da kuke buƙata. Misali, mun cire alamar padding-topshigar da rediyon mu da ke kan tambarin radiyo don daidaita layin rubutu da kyau.

Rediyo
Akwatin ajiya
<form>
  <div class="form-group row">
    <label for="inputEmail3" class="col-sm-2 col-form-label">Email</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
    </div>
  </div>
  <div class="form-group row">
    <label for="inputPassword3" class="col-sm-2 col-form-label">Password</label>
    <div class="col-sm-10">
      <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
    </div>
  </div>
  <fieldset class="form-group">
    <div class="row">
      <legend class="col-form-label col-sm-2 pt-0">Radios</legend>
      <div class="col-sm-10">
        <div class="form-check">
          <input class="form-check-input" type="radio" name="gridRadios" id="gridRadios1" value="option1" checked>
          <label class="form-check-label" for="gridRadios1">
            First radio
          </label>
        </div>
        <div class="form-check">
          <input class="form-check-input" type="radio" name="gridRadios" id="gridRadios2" value="option2">
          <label class="form-check-label" for="gridRadios2">
            Second radio
          </label>
        </div>
        <div class="form-check disabled">
          <input class="form-check-input" type="radio" name="gridRadios" id="gridRadios3" value="option3" disabled>
          <label class="form-check-label" for="gridRadios3">
            Third disabled radio
          </label>
        </div>
      </div>
    </div>
  </fieldset>
  <div class="form-group row">
    <div class="col-sm-2">Checkbox</div>
    <div class="col-sm-10">
      <div class="form-check">
        <input class="form-check-input" type="checkbox" id="gridCheck1">
        <label class="form-check-label" for="gridCheck1">
          Example checkbox
        </label>
      </div>
    </div>
  </div>
  <div class="form-group row">
    <div class="col-sm-10">
      <button type="submit" class="btn btn-primary">Sign in</button>
    </div>
  </div>
</form>
Girman nau'in lakabin kwance

Tabbatar amfani da .col-form-label-smko .col-form-label-lgzuwa ga <label>s ko <legend>s ɗin ku don bi daidai girman girman .form-control-lgda .form-control-sm.

<form>
  <div class="form-group row">
    <label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Email</label>
    <div class="col-sm-10">
      <input type="email" class="form-control form-control-sm" id="colFormLabelSm" placeholder="col-form-label-sm">
    </div>
  </div>
  <div class="form-group row">
    <label for="colFormLabel" class="col-sm-2 col-form-label">Email</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="colFormLabel" placeholder="col-form-label">
    </div>
  </div>
  <div class="form-group row">
    <label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg">Email</label>
    <div class="col-sm-10">
      <input type="email" class="form-control form-control-lg" id="colFormLabelLg" placeholder="col-form-label-lg">
    </div>
  </div>
</form>

Girman ginshiƙi

Kamar yadda aka nuna a cikin misalan da suka gabata, tsarin grid ɗinmu yana ba ku damar sanya kowane adadin .cols a cikin wani .rowko .form-row. Za su raba faɗin da ke akwai daidai tsakanin su. Hakanan kuna iya zaɓar juzu'in ginshiƙan ku don ɗaukar sarari ko žasa, yayin da sauran .cols ɗin suka raba daidai da sauran, tare da takamaiman azuzuwan shafi kamar .col-7.

<form>
  <div class="form-row">
    <div class="col-7">
      <input type="text" class="form-control" placeholder="City">
    </div>
    <div class="col">
      <input type="text" class="form-control" placeholder="State">
    </div>
    <div class="col">
      <input type="text" class="form-control" placeholder="Zip">
    </div>
  </div>
</form>

Girman atomatik

Misalin da ke ƙasa yana amfani da kayan aikin flexbox don a tsaye a tsakiya abubuwan da ke ciki da canje-canje .colzuwa ta .col-autoyadda ginshiƙan ku kawai su ɗauki sarari gwargwadon buƙata. Sanya wata hanya, ginshiƙi yana girman kansa bisa abubuwan da ke ciki.

@
<form>
  <div class="form-row align-items-center">
    <div class="col-auto">
      <label class="sr-only" for="inlineFormInput">Name</label>
      <input type="text" class="form-control mb-2" id="inlineFormInput" placeholder="Jane Doe">
    </div>
    <div class="col-auto">
      <label class="sr-only" for="inlineFormInputGroup">Username</label>
      <div class="input-group mb-2">
        <div class="input-group-prepend">
          <div class="input-group-text">@</div>
        </div>
        <input type="text" class="form-control" id="inlineFormInputGroup" placeholder="Username">
      </div>
    </div>
    <div class="col-auto">
      <div class="form-check mb-2">
        <input class="form-check-input" type="checkbox" id="autoSizingCheck">
        <label class="form-check-label" for="autoSizingCheck">
          Remember me
        </label>
      </div>
    </div>
    <div class="col-auto">
      <button type="submit" class="btn btn-primary mb-2">Submit</button>
    </div>
  </div>
</form>

Kuna iya sake haɗa wannan tare da takamaiman azuzuwan shafi mai girma.

@
<form>
  <div class="form-row align-items-center">
    <div class="col-sm-3 my-1">
      <label class="sr-only" for="inlineFormInputName">Name</label>
      <input type="text" class="form-control" id="inlineFormInputName" placeholder="Jane Doe">
    </div>
    <div class="col-sm-3 my-1">
      <label class="sr-only" for="inlineFormInputGroupUsername">Username</label>
      <div class="input-group">
        <div class="input-group-prepend">
          <div class="input-group-text">@</div>
        </div>
        <input type="text" class="form-control" id="inlineFormInputGroupUsername" placeholder="Username">
      </div>
    </div>
    <div class="col-auto my-1">
      <div class="form-check">
        <input class="form-check-input" type="checkbox" id="autoSizingCheck2">
        <label class="form-check-label" for="autoSizingCheck2">
          Remember me
        </label>
      </div>
    </div>
    <div class="col-auto my-1">
      <button type="submit" class="btn btn-primary">Submit</button>
    </div>
  </div>
</form>

Kuma ba shakka ana tallafawa sarrafa tsari na al'ada .

<form>
  <div class="form-row align-items-center">
    <div class="col-auto my-1">
      <label class="mr-sm-2" for="inlineFormCustomSelect">Preference</label>
      <select class="custom-select mr-sm-2" id="inlineFormCustomSelect">
        <option selected>Choose...</option>
        <option value="1">One</option>
        <option value="2">Two</option>
        <option value="3">Three</option>
      </select>
    </div>
    <div class="col-auto my-1">
      <div class="custom-control custom-checkbox mr-sm-2">
        <input type="checkbox" class="custom-control-input" id="customControlAutosizing">
        <label class="custom-control-label" for="customControlAutosizing">Remember my preference</label>
      </div>
    </div>
    <div class="col-auto my-1">
      <button type="submit" class="btn btn-primary">Submit</button>
    </div>
  </div>
</form>

Siffofin layi

Yi amfani da .form-inlineajin don nuna jerin lakabi, sarrafawar tsari, da maɓalli a jere ɗaya a kwance. Gudanar da tsari a cikin siffofin layi ya bambanta kaɗan daga tsoffin jihohin su.

  • Sarrafa su ne display: flex, ruguza duk wani farin sarari na HTML kuma yana ba ku damar samar da sarrafa jeri tare da tazara da kayan aikin flexbox .
  • Ƙungiyoyin sarrafawa da shigarwa suna karɓa width: autodon soke tsohowar Bootstrap width: 100%.
  • Sarrafa yana bayyana layi ɗaya kawai a cikin wuraren kallo waɗanda ke da faɗin aƙalla 576px don lissafin kunkuntar wuraren kallo akan na'urorin hannu.

Kuna iya buƙatar magance nisa da jeri na nau'ikan sarrafa nau'i ɗaya tare da abubuwan amfani tazara (kamar yadda aka nuna a ƙasa). A ƙarshe, tabbatar da haɗawa koyaushe <label>tare da kowane nau'i sarrafa nau'i, ko da kuna buƙatar ɓoye shi daga baƙi marasa karanta allo tare da .sr-only.

@
<form class="form-inline">
  <label class="sr-only" for="inlineFormInputName2">Name</label>
  <input type="text" class="form-control mb-2 mr-sm-2" id="inlineFormInputName2" placeholder="Jane Doe">

  <label class="sr-only" for="inlineFormInputGroupUsername2">Username</label>
  <div class="input-group mb-2 mr-sm-2">
    <div class="input-group-prepend">
      <div class="input-group-text">@</div>
    </div>
    <input type="text" class="form-control" id="inlineFormInputGroupUsername2" placeholder="Username">
  </div>

  <div class="form-check mb-2 mr-sm-2">
    <input class="form-check-input" type="checkbox" id="inlineFormCheck">
    <label class="form-check-label" for="inlineFormCheck">
      Remember me
    </label>
  </div>

  <button type="submit" class="btn btn-primary mb-2">Submit</button>
</form>

Hakanan ana goyan bayan sarrafa fom na al'ada da zaɓi.

<form class="form-inline">
  <label class="my-1 mr-2" for="inlineFormCustomSelectPref">Preference</label>
  <select class="custom-select my-1 mr-sm-2" id="inlineFormCustomSelectPref">
    <option selected>Choose...</option>
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>
  </select>

  <div class="custom-control custom-checkbox my-1 mr-sm-2">
    <input type="checkbox" class="custom-control-input" id="customControlInline">
    <label class="custom-control-label" for="customControlInline">Remember my preference</label>
  </div>

  <button type="submit" class="btn btn-primary my-1">Submit</button>
</form>
Madadin maɓallan ɓoye

Fasaha masu taimako kamar masu karanta allo za su sami matsala tare da fom ɗinku idan ba ku haɗa da lakabin kowane shigarwa ba. Don waɗannan nau'ikan layi, zaku iya ɓoye alamun ta amfani da .sr-onlyajin. Akwai ƙarin hanyoyin hanyoyin samar da lakabi don fasahar taimako, kamar aria-label, aria-labelledbyko titlesifa. Idan babu ɗayan waɗannan, fasahar taimako na iya yin amfani da placeholdersifa, idan akwai, amma lura cewa placeholderba a ba da shawarar amfani da azaman madadin wasu hanyoyin yin lakabi ba.

Taimako rubutu

Ana iya ƙirƙirar rubutun taimako na toshewa a cikin nau'i ta amfani da .form-text(wanda aka sani a baya .help-blocka v3). Za a iya aiwatar da rubutun taimakon layi cikin sassauƙa ta amfani da kowane ɓangaren HTML na layi da azuzuwan masu amfani kamar .text-muted.

Haɗa rubutun taimako tare da sarrafa tsari

Rubutun taimako ya kamata a haɗa shi a fili tare da sarrafa nau'i wanda ya shafi amfani da aria-describedbysifa. Wannan zai tabbatar da cewa fasahar taimako-kamar masu karanta allo-zasu sanar da wannan rubutun taimako lokacin da mai amfani ya mai da hankali ko shigar da sarrafawa.

Ana iya tsara rubutun taimako da ke ƙasa abubuwan shigarwa da .form-text. Wannan ajin ya haɗa display: blockda ƙara wasu babban gefe don sauƙin tazara daga abubuwan da ke sama.

Dole ne kalmar wucewar ku ta kasance tsawon haruffa 8-20, ta ƙunshi haruffa da lambobi, kuma kada ta ƙunshi sarari, haruffa na musamman, ko emoji.
<label for="inputPassword5">Password</label>
<input type="password" id="inputPassword5" class="form-control" aria-describedby="passwordHelpBlock">
<small id="passwordHelpBlock" class="form-text text-muted">
  Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
</small>

Rubutun cikin layi na iya amfani da kowane nau'in HTML na layi na yau da kullun (zama a <small>, <span>, ko wani abu dabam) ba tare da komai ba sai aji mai amfani.

Dole ne ya zama tsayin haruffa 8-20.
<form class="form-inline">
  <div class="form-group">
    <label for="inputPassword6">Password</label>
    <input type="password" id="inputPassword6" class="form-control mx-sm-3" aria-describedby="passwordHelpInline">
    <small id="passwordHelpInline" class="text-muted">
      Must be 8-20 characters long.
    </small>
  </div>
</form>

Siffofin naƙasassu

Ƙara disabledsifa ta boolean akan shigarwa don hana hulɗar mai amfani da sanya ta zama mai sauƙi.

<input class="form-control" id="disabledInput" type="text" placeholder="Disabled input here..." disabled>

Ƙara disabledsifa zuwa wani <fieldset>don kashe duk abubuwan sarrafawa a ciki.

<form>
  <fieldset disabled>
    <div class="form-group">
      <label for="disabledTextInput">Disabled input</label>
      <input type="text" id="disabledTextInput" class="form-control" placeholder="Disabled input">
    </div>
    <div class="form-group">
      <label for="disabledSelect">Disabled select menu</label>
      <select id="disabledSelect" class="form-control">
        <option>Disabled select</option>
      </select>
    </div>
    <div class="form-check">
      <input class="form-check-input" type="checkbox" id="disabledFieldsetCheck" disabled>
      <label class="form-check-label" for="disabledFieldsetCheck">
        Can't check this
      </label>
    </div>
    <button type="submit" class="btn btn-primary">Submit</button>
  </fieldset>
</form>
Caveat tare da anga

Ta hanyar tsoho, masu bincike za su kula da duk sarrafa nau'i na asali ( <input>, <select>da <button>abubuwa) a cikin <fieldset disabled>nakasassu, suna hana mu'amalar madannai da linzamin kwamfuta a kansu. Koyaya, idan fom ɗin ku kuma ya haɗa da <a ... class="btn btn-*">abubuwa, waɗannan za a ba su salon pointer-events: none. Kamar yadda aka lura a cikin sashin game da yanayin nakasa don maɓalli (kuma musamman a cikin ƙaramin yanki don abubuwan anga), wannan kadarar CSS ba ta riga ta daidaita ba kuma ba ta da cikakken tallafi a cikin Opera 18 da ƙasa, ko a cikin Internet Explorer 10, kuma ta ci nasara. 't hana masu amfani da madannai damar mayar da hankali ko kunna waɗannan hanyoyin haɗin. Don haka don zama lafiya, yi amfani da JavaScript na al'ada don kashe irin waɗannan hanyoyin haɗin.

Daidaita-browser

Yayin da Bootstrap zai yi amfani da waɗannan salon a cikin duk masu bincike, Internet Explorer 11 da ƙasa ba sa cikakken goyon bayan disabledsifa akan <fieldset>. Yi amfani da JavaScript na al'ada don kashe saitin filin a cikin waɗannan masu binciken.

Tabbatarwa

Bayar da ra'ayi mai mahimmanci, mai iya aiki ga masu amfani da ku tare da ingantaccen tsari na HTML5- akwai a cikin duk masu binciken mu masu goyan baya . Zaɓi daga bayanan ingantattun bayanan mai bincike, ko aiwatar da saƙon na al'ada tare da ginanniyar azuzuwan mu da JavaScript mai farawa.

Muna ba da shawara sosai ga salon tabbatarwa na al'ada kamar yadda ba a sanar da ma'anar ma'amala ta asali ga masu karatun allo ba.

Yadda yake aiki

Anan ga yadda ingantaccen tsari ke aiki tare da Bootstrap:

  • Ana amfani da ingantaccen tsarin HTML ta hanyar azuzuwan ɓarna biyu na CSS, :invalidda :valid. Ya shafi <input>, <select>, da <textarea>abubuwa.
  • Bootstrap ya keɓanta da salo :invalidda :validsalo zuwa ajin iyaye .was-validated, yawanci ana amfani da su ga <form>. In ba haka ba, kowane filin da ake buƙata ba tare da ƙima yana nunawa a matsayin mara inganci akan nauyin shafi. Ta wannan hanyar, zaku iya zaɓar lokacin kunna su (yawanci bayan an yi ƙoƙarin ƙaddamar da fom).
  • A matsayin koma baya, .is-invalidkuma .is-validana iya amfani da azuzuwan maimakon azuzuwan ƙididdiga don tabbatar da gefen uwar garken . Ba sa buƙatar .was-validatedajin iyaye.
  • Saboda ƙuntatawa a cikin yadda CSS ke aiki, ba za mu iya (a halin yanzu) amfani da salo ga <label>wanda ya zo gaban sarrafa tsari a cikin DOM ba tare da taimakon JavaScript na al'ada ba.
  • Duk masu bincike na zamani suna goyan bayan ingantaccen ingantaccen API , jerin hanyoyin JavaScript don tabbatar da sarrafa tsari.
  • Saƙonnin mayar da martani na iya yin amfani da abubuwan da suka dace na burauza (mabambanta ga kowane mai bincike, kuma wanda ba za a iya salo ta hanyar CSS ba) ko salon martani na al'ada tare da ƙarin HTML da CSS.
  • Kuna iya samar da saƙon ingantacce na al'ada da su setCustomValiditya cikin JavaScript.

Tare da wannan a zuciya, yi la'akari da fa'idodin demos masu zuwa don salon ingantaccen sigar mu ta al'ada, azuzuwan gefen uwar garken zaɓi, da maƙasudin burauza.

Salon al'ada

Don saƙon ingantaccen tsari na Bootstrap na al'ada, kuna buƙatar ƙara novalidatesifa ta boolean zuwa <form>. Wannan yana hana tsoffin bayanan bayanan kayan aikin mai bincike, amma har yanzu yana ba da dama ga API ɗin ingantaccen tsari a JavaScript. Yi ƙoƙarin ƙaddamar da fom ɗin da ke ƙasa; JavaScript ɗin mu zai katse maɓallin ƙaddamarwa kuma ya ba da amsa gare ku.

Lokacin ƙoƙarin ƙaddamarwa, za ku ga da :invalidkuma :validsalon da aka yi amfani da su akan sarrafa fom ɗin ku.

Looks good!
Looks good!
@
Please choose a username.
Please provide a valid city.
Please provide a valid state.
Please provide a valid zip.
You must agree before submitting.
<form class="needs-validation" novalidate>
  <div class="form-row">
    <div class="col-md-4 mb-3">
      <label for="validationCustom01">First name</label>
      <input type="text" class="form-control" id="validationCustom01" placeholder="First name" value="Mark" required>
      <div class="valid-feedback">
        Looks good!
      </div>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationCustom02">Last name</label>
      <input type="text" class="form-control" id="validationCustom02" placeholder="Last name" value="Otto" required>
      <div class="valid-feedback">
        Looks good!
      </div>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationCustomUsername">Username</label>
      <div class="input-group">
        <div class="input-group-prepend">
          <span class="input-group-text" id="inputGroupPrepend">@</span>
        </div>
        <input type="text" class="form-control" id="validationCustomUsername" placeholder="Username" aria-describedby="inputGroupPrepend" required>
        <div class="invalid-feedback">
          Please choose a username.
        </div>
      </div>
    </div>
  </div>
  <div class="form-row">
    <div class="col-md-6 mb-3">
      <label for="validationCustom03">City</label>
      <input type="text" class="form-control" id="validationCustom03" placeholder="City" required>
      <div class="invalid-feedback">
        Please provide a valid city.
      </div>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationCustom04">State</label>
      <input type="text" class="form-control" id="validationCustom04" placeholder="State" required>
      <div class="invalid-feedback">
        Please provide a valid state.
      </div>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationCustom05">Zip</label>
      <input type="text" class="form-control" id="validationCustom05" placeholder="Zip" required>
      <div class="invalid-feedback">
        Please provide a valid zip.
      </div>
    </div>
  </div>
  <div class="form-group">
    <div class="form-check">
      <input class="form-check-input" type="checkbox" value="" id="invalidCheck" required>
      <label class="form-check-label" for="invalidCheck">
        Agree to terms and conditions
      </label>
      <div class="invalid-feedback">
        You must agree before submitting.
      </div>
    </div>
  </div>
  <button class="btn btn-primary" type="submit">Submit form</button>
</form>

<script>
// Example starter JavaScript for disabling form submissions if there are invalid fields
(function() {
  'use strict';
  window.addEventListener('load', function() {
    // Fetch all the forms we want to apply custom Bootstrap validation styles to
    var forms = document.getElementsByClassName('needs-validation');
    // Loop over them and prevent submission
    var validation = Array.prototype.filter.call(forms, function(form) {
      form.addEventListener('submit', function(event) {
        if (form.checkValidity() === false) {
          event.preventDefault();
          event.stopPropagation();
        }
        form.classList.add('was-validated');
      }, false);
    });
  }, false);
})();
</script>

Matsalolin Browser

Ba ku da sha'awar saƙon martani na tabbatarwa na al'ada ko rubuta JavaScript don canza halayen tsari? Da kyau, zaku iya amfani da abubuwan da ba a iya amfani da su ba. Gwada ƙaddamar da fom ɗin da ke ƙasa. Dangane da burauzar ku da kuma OS, zaku ga salon ra'ayi daban-daban.

Duk da yake waɗannan salon amsa ba za a iya sa su tare da CSS ba, har yanzu kuna iya keɓance rubutun ra'ayin ta hanyar JavaScript.

@
<form>
  <div class="form-row">
    <div class="col-md-4 mb-3">
      <label for="validationDefault01">First name</label>
      <input type="text" class="form-control" id="validationDefault01" placeholder="First name" value="Mark" required>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationDefault02">Last name</label>
      <input type="text" class="form-control" id="validationDefault02" placeholder="Last name" value="Otto" required>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationDefaultUsername">Username</label>
      <div class="input-group">
        <div class="input-group-prepend">
          <span class="input-group-text" id="inputGroupPrepend2">@</span>
        </div>
        <input type="text" class="form-control" id="validationDefaultUsername" placeholder="Username" aria-describedby="inputGroupPrepend2" required>
      </div>
    </div>
  </div>
  <div class="form-row">
    <div class="col-md-6 mb-3">
      <label for="validationDefault03">City</label>
      <input type="text" class="form-control" id="validationDefault03" placeholder="City" required>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationDefault04">State</label>
      <input type="text" class="form-control" id="validationDefault04" placeholder="State" required>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationDefault05">Zip</label>
      <input type="text" class="form-control" id="validationDefault05" placeholder="Zip" required>
    </div>
  </div>
  <div class="form-group">
    <div class="form-check">
      <input class="form-check-input" type="checkbox" value="" id="invalidCheck2" required>
      <label class="form-check-label" for="invalidCheck2">
        Agree to terms and conditions
      </label>
    </div>
  </div>
  <button class="btn btn-primary" type="submit">Submit form</button>
</form>

Gefen uwar garken

Muna ba da shawarar yin amfani da ingantaccen gefen abokin ciniki, amma idan kuna buƙatar gefen uwar garken, zaku iya nuna mara inganci da filayen fom tare .is-invalidda .is-valid. Lura cewa .invalid-feedbackkuma ana goyan bayan waɗannan azuzuwan.

Yayi kyau!
Yayi kyau!
@
Da fatan za a zaɓi sunan mai amfani.
Da fatan za a samar da ingantaccen birni.
Da fatan za a ba da ingantaccen yanayi.
Da fatan za a ba da ingantaccen zip.
Dole ne ku yarda kafin ƙaddamarwa.
<form>
  <div class="form-row">
    <div class="col-md-4 mb-3">
      <label for="validationServer01">First name</label>
      <input type="text" class="form-control is-valid" id="validationServer01" placeholder="First name" value="Mark" required>
      <div class="valid-feedback">
        Looks good!
      </div>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationServer02">Last name</label>
      <input type="text" class="form-control is-valid" id="validationServer02" placeholder="Last name" value="Otto" required>
      <div class="valid-feedback">
        Looks good!
      </div>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationServerUsername">Username</label>
      <div class="input-group">
        <div class="input-group-prepend">
          <span class="input-group-text" id="inputGroupPrepend3">@</span>
        </div>
        <input type="text" class="form-control is-invalid" id="validationServerUsername" placeholder="Username" aria-describedby="inputGroupPrepend3" required>
        <div class="invalid-feedback">
          Please choose a username.
        </div>
      </div>
    </div>
  </div>
  <div class="form-row">
    <div class="col-md-6 mb-3">
      <label for="validationServer03">City</label>
      <input type="text" class="form-control is-invalid" id="validationServer03" placeholder="City" required>
      <div class="invalid-feedback">
        Please provide a valid city.
      </div>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationServer04">State</label>
      <input type="text" class="form-control is-invalid" id="validationServer04" placeholder="State" required>
      <div class="invalid-feedback">
        Please provide a valid state.
      </div>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationServer05">Zip</label>
      <input type="text" class="form-control is-invalid" id="validationServer05" placeholder="Zip" required>
      <div class="invalid-feedback">
        Please provide a valid zip.
      </div>
    </div>
  </div>
  <div class="form-group">
    <div class="form-check">
      <input class="form-check-input is-invalid" type="checkbox" value="" id="invalidCheck3" required>
      <label class="form-check-label" for="invalidCheck3">
        Agree to terms and conditions
      </label>
      <div class="invalid-feedback">
        You must agree before submitting.
      </div>
    </div>
  </div>
  <button class="btn btn-primary" type="submit">Submit form</button>
</form>

Abubuwan tallafi

Siffofin misalin mu suna nuna <input>s na asali na rubutu a sama, amma akwai salon ingantaccen tsari don sarrafa sigar mu ta al'ada, kuma.

Misali rubutun amsa mara inganci
Ƙarin misali rubutu mara inganci
Misali na al'ada mara inganci zaɓi martani
Misali ra'ayin fayil na al'ada mara inganci
<form class="was-validated">
  <div class="custom-control custom-checkbox mb-3">
    <input type="checkbox" class="custom-control-input" id="customControlValidation1" required>
    <label class="custom-control-label" for="customControlValidation1">Check this custom checkbox</label>
    <div class="invalid-feedback">Example invalid feedback text</div>
  </div>

  <div class="custom-control custom-radio">
    <input type="radio" class="custom-control-input" id="customControlValidation2" name="radio-stacked" required>
    <label class="custom-control-label" for="customControlValidation2">Toggle this custom radio</label>
  </div>
  <div class="custom-control custom-radio mb-3">
    <input type="radio" class="custom-control-input" id="customControlValidation3" name="radio-stacked" required>
    <label class="custom-control-label" for="customControlValidation3">Or toggle this other custom radio</label>
    <div class="invalid-feedback">More example invalid feedback text</div>
  </div>

  <div class="form-group">
    <select class="custom-select" required>
      <option value="">Open this select menu</option>
      <option value="1">One</option>
      <option value="2">Two</option>
      <option value="3">Three</option>
    </select>
    <div class="invalid-feedback">Example invalid custom select feedback</div>
  </div>

  <div class="custom-file">
    <input type="file" class="custom-file-input" id="validatedCustomFile" required>
    <label class="custom-file-label" for="validatedCustomFile">Choose file...</label>
    <div class="invalid-feedback">Example invalid custom file feedback</div>
  </div>
</form>

Nasihun kayan aiki

Idan shimfidar tsari na ku ya ba shi damar, zaku iya musanya .{valid|invalid}-feedbackazuzuwan don .{valid|invalid}-tooltipazuzuwan don nuna ra'ayoyin ingantawa a cikin salo mai salo na kayan aiki. Tabbatar cewa kuna da iyaye tare da position: relativeshi don saka kayan aiki. A cikin misalin da ke ƙasa, azuzuwan rukunin mu sun riga sun sami wannan, amma aikinku na iya buƙatar saitin madadin.

Looks good!
Looks good!
@
Please choose a unique and valid username.
Please provide a valid city.
Please provide a valid state.
Please provide a valid zip.
<form class="needs-validation" novalidate>
  <div class="form-row">
    <div class="col-md-4 mb-3">
      <label for="validationTooltip01">First name</label>
      <input type="text" class="form-control" id="validationTooltip01" placeholder="First name" value="Mark" required>
      <div class="valid-tooltip">
        Looks good!
      </div>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationTooltip02">Last name</label>
      <input type="text" class="form-control" id="validationTooltip02" placeholder="Last name" value="Otto" required>
      <div class="valid-tooltip">
        Looks good!
      </div>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationTooltipUsername">Username</label>
      <div class="input-group">
        <div class="input-group-prepend">
          <span class="input-group-text" id="validationTooltipUsernamePrepend">@</span>
        </div>
        <input type="text" class="form-control" id="validationTooltipUsername" placeholder="Username" aria-describedby="validationTooltipUsernamePrepend" required>
        <div class="invalid-tooltip">
          Please choose a unique and valid username.
        </div>
      </div>
    </div>
  </div>
  <div class="form-row">
    <div class="col-md-6 mb-3">
      <label for="validationTooltip03">City</label>
      <input type="text" class="form-control" id="validationTooltip03" placeholder="City" required>
      <div class="invalid-tooltip">
        Please provide a valid city.
      </div>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationTooltip04">State</label>
      <input type="text" class="form-control" id="validationTooltip04" placeholder="State" required>
      <div class="invalid-tooltip">
        Please provide a valid state.
      </div>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationTooltip05">Zip</label>
      <input type="text" class="form-control" id="validationTooltip05" placeholder="Zip" required>
      <div class="invalid-tooltip">
        Please provide a valid zip.
      </div>
    </div>
  </div>
  <button class="btn btn-primary" type="submit">Submit form</button>
</form>

Siffofin al'ada

Don ƙarin keɓancewa da daidaitawar burauza, yi amfani da abubuwan mu na al'ada gabaɗaya don maye gurbin abubuwan da suka dace. An gina su a saman nazarce-nazarce da alamar iya samun dama, don haka suna da ƙwaƙƙwaran musanyawa ga kowane nau'i na tsoho.

Akwatunan rajista da rediyo

Kowane akwati da rediyo an nannade shi a cikin <div>wani ɗan'uwa <span>don ƙirƙirar sarrafa mu na al'ada da kuma <label>don rubutun da ke gaba. A tsari, wannan hanya ɗaya ce ta tsoho .form-check.

Muna amfani da zaɓin ƴan uwa ( ~) ga duk <input>jihohinmu-kamar- :checkeddon yin salon ƙirar ƙirar mu da kyau. Lokacin da aka haɗa shi da .custom-control-labelajin, za mu iya kuma salon rubutun ga kowane abu dangane da yanayin <input>'yanayin.

Muna ɓoye tsoho <input>tare opacityda amfani da .custom-control-labeldon gina sabon alamar sigar al'ada a wurin sa tare ::beforeda ::after. Abin baƙin ciki ba za mu iya gina al'ada daya daga kawai <input>saboda CSS's contentba ya aiki a kan wannan kashi.

A cikin jihohin da aka bincika, muna amfani da gunkin SVG mai tushe64 daga Buɗe Iconic . Wannan yana ba mu mafi kyawun sarrafawa don salo da sakawa a cikin masu bincike da na'urori.

Akwatunan bincike

<div class="custom-control custom-checkbox">
  <input type="checkbox" class="custom-control-input" id="customCheck1">
  <label class="custom-control-label" for="customCheck1">Check this custom checkbox</label>
</div>

Akwatunan rajista na al'ada kuma na iya amfani da :indeterminateajin ƙididdiga lokacin da aka saita da hannu ta JavaScript (babu wani sifa na HTML don tantance shi).

Idan kana amfani da jQuery, wani abu kamar wannan ya isa:

$('.your-checkbox').prop('indeterminate', true)

Rediyo

<div class="custom-control custom-radio">
  <input type="radio" id="customRadio1" name="customRadio" class="custom-control-input">
  <label class="custom-control-label" for="customRadio1">Toggle this custom radio</label>
</div>
<div class="custom-control custom-radio">
  <input type="radio" id="customRadio2" name="customRadio" class="custom-control-input">
  <label class="custom-control-label" for="customRadio2">Or toggle this other custom radio</label>
</div>

Layin layi

<div class="custom-control custom-radio custom-control-inline">
  <input type="radio" id="customRadioInline1" name="customRadioInline1" class="custom-control-input">
  <label class="custom-control-label" for="customRadioInline1">Toggle this custom radio</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
  <input type="radio" id="customRadioInline2" name="customRadioInline1" class="custom-control-input">
  <label class="custom-control-label" for="customRadioInline2">Or toggle this other custom radio</label>
</div>

An kashe

Hakanan za'a iya kashe akwatunan rajista da rediyo na musamman. Ƙara disabledsifa ta boolean zuwa ga <input>kuma alamar al'ada da bayanin alamar za a yi salo ta atomatik.

<div class="custom-control custom-checkbox">
  <input type="checkbox" class="custom-control-input" id="customCheckDisabled" disabled>
  <label class="custom-control-label" for="customCheckDisabled">Check this custom checkbox</label>
</div>

<div class="custom-control custom-radio">
  <input type="radio" id="radio3" name="radioDisabled" id="customRadioDisabled" class="custom-control-input" disabled>
  <label class="custom-control-label" for="customRadioDisabled">Toggle this custom radio</label>
</div>

Zaɓi menu

Menu na al'ada <select>yana buƙatar aji na al'ada kawai, .custom-selectdon jawo salo na al'ada.

<select class="custom-select">
  <option selected>Open this select menu</option>
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
</select>

Hakanan kuna iya zaɓar daga ƙanana da manyan zaɓaɓɓun al'ada don dacewa da madaidaitan abubuwan shigar da rubutu na mu.

<select class="custom-select custom-select-lg mb-3">
  <option selected>Open this select menu</option>
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
</select>

<select class="custom-select custom-select-sm">
  <option selected>Open this select menu</option>
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
</select>

Hakanan multipleana tallafawa sifa:

<select class="custom-select" multiple>
  <option selected>Open this select menu</option>
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
</select>

Kamar yadda sizesifa ce:

<select class="custom-select" size="3">
  <option selected>Open this select menu</option>
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
</select>

Mai binciken fayil

Shigar da fayil ɗin shine mafi girman gungun kuma yana buƙatar ƙarin JavaScript idan kuna son haɗa su da aikin Zaɓi fayil… da zaɓin rubutun sunan fayil.

<div class="custom-file">
  <input type="file" class="custom-file-input" id="customFile">
  <label class="custom-file-label" for="customFile">Choose file</label>
</div>

We hide the default file <input> via opacity and instead style the <label>. The button is generated and positioned with ::after. Lastly, we declare a width and height on the <input> for proper spacing for surrounding content.

Translating or customizing the strings

The :lang() pseudo-class is used to allow for translation of the “Browse” text into other languages. Override or add entries to the $custom-file-text Sass variable with the relevant language tag and localized strings. The English strings can be customized the same way. For example, here’s how one might add a Spanish translation (Spanish’s language code is es):

$custom-file-text: (
  en: "Browse",
  es: "Elegir"
);

Here’s lang(es) in action on the custom file input for a Spanish translation:

<div class="custom-file">
  <input type="file" class="custom-file-input" id="customFileLang" lang="es">
  <label class="custom-file-label" for="customFileLang">Seleccionar Archivo</label>
</div>

Kuna buƙatar saita harshen takaddar ku (ko bishiyar ta) daidai domin a nuna madaidaicin rubutu. Ana iya yin wannan ta amfani da langsifa akan sifa <html>ko Content-Languagetaken HTTP , a tsakanin sauran hanyoyin.