Holo i ka ʻike nui Holo i ka hoʻokele docs
Check
in English

Hoʻolālā

Hāʻawi i kāu mau palapala i ka hoʻolālā—mai ka laina laina a hiki i ka hoʻokō ʻana i ka mānoanoa maʻamau—me kā mākou mau koho hoʻolālā puka.

Nā palapala

Pono kēlā me kēia pūʻulu o nā kahua puka i kahi <form>mea. ʻAʻole hāʻawi ʻo Bootstrap i ke ʻano paʻamau no ka <form>mea, akā aia kekahi mau hiʻohiʻona mākaʻikaʻi ikaika i hāʻawi ʻia e ka paʻamau.

  • He mea hou i nā palapala polokalamu kele pūnaewele? E noʻonoʻo e nānā i nā palapala palapala MDN no ka ʻike nui a me ka papa inoa piha o nā ʻano i loaʻa.
  • <button>s i loko o kahi <form>paʻamau i type="submit", no laila e hoʻoikaika i ka kikoʻī a hoʻokomo mau i kahi type.

No ka mea e pili ana ʻo Bootstrap display: blocka width: 100%kokoke i kā mākou mau mana ʻano āpau, e hoʻopaʻa paʻa ʻia nā palapala ma ke kū pololei. Hiki ke hoʻohana ʻia nā papa ʻē aʻe e hoʻololi i kēia hoʻolālā ma ke ʻano o kēlā me kēia.

Nā pono hana

ʻO nā pono hana margin ke ala maʻalahi loa e hoʻohui i kekahi ʻano i nā ʻano. Hāʻawi lākou i ka hui pū ʻana o nā lepili, nā mana, nā kikokikona palapala koho, a me nā memo hōʻoia. Manaʻo mākou e hoʻopili i margin-bottomnā pono hana, a me ka hoʻohana ʻana i hoʻokahi kuhikuhi i loko o ke ʻano no ka kūlike.

E ʻoluʻolu e kūkulu i kāu mau palapala e like me kou makemake, me <fieldset>s, <div>s, a i ʻole kekahi mea ʻē aʻe.

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

Puka puka

Hiki ke kūkulu ʻia nā ʻano mea paʻakikī me ka hoʻohana ʻana i kā mākou mau papa grid. E hoʻohana i kēia no nā hoʻolālā puka e koi ana i nā kolamu he nui, nā laula like ʻole, a me nā koho alignment hou. Pono ka $enable-grid-classeshoʻololi Sass e ʻae ʻia (ma ke ʻano paʻamau).

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

ʻAuwai

Ma ka hoʻohui ʻana i nā papa hoʻololi auwai , hiki iā ʻoe ke hoʻomalu i ka laulā auwai a me ka inline e like me ke kuhikuhi poloka. Pono nō hoʻi e $enable-grid-classeshiki ke hoʻololi ʻia ka hoʻololi Sass (ma ka paʻamau).

html
<div class="row g-3">
  <div class="col">
    <input type="text" class="form-control" placeholder="First name" aria-label="First name">
  </div>
  <div class="col">
    <input type="text" class="form-control" placeholder="Last name" aria-label="Last name">
  </div>
</div>

Hiki ke hana ʻia nā hoʻolālā paʻakikī me ka ʻōnaehana grid.

html
<form class="row g-3">
  <div class="col-md-6">
    <label for="inputEmail4" class="form-label">Email</label>
    <input type="email" class="form-control" id="inputEmail4">
  </div>
  <div class="col-md-6">
    <label for="inputPassword4" class="form-label">Password</label>
    <input type="password" class="form-control" id="inputPassword4">
  </div>
  <div class="col-12">
    <label for="inputAddress" class="form-label">Address</label>
    <input type="text" class="form-control" id="inputAddress" placeholder="1234 Main St">
  </div>
  <div class="col-12">
    <label for="inputAddress2" class="form-label">Address 2</label>
    <input type="text" class="form-control" id="inputAddress2" placeholder="Apartment, studio, or floor">
  </div>
  <div class="col-md-6">
    <label for="inputCity" class="form-label">City</label>
    <input type="text" class="form-control" id="inputCity">
  </div>
  <div class="col-md-4">
    <label for="inputState" class="form-label">State</label>
    <select id="inputState" class="form-select">
      <option selected>Choose...</option>
      <option>...</option>
    </select>
  </div>
  <div class="col-md-2">
    <label for="inputZip" class="form-label">Zip</label>
    <input type="text" class="form-control" id="inputZip">
  </div>
  <div class="col-12">
    <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>
  <div class="col-12">
    <button type="submit" class="btn btn-primary">Sign in</button>
  </div>
</form>

ʻAno ʻeleʻele

E hana i nā ʻano ākea me ka mākia ma ka hoʻohui ʻana i ka .rowpapa e hana i nā hui a me ka hoʻohana ʻana i nā .col-*-*papa e kuhikuhi i ka laulā o kāu mau lepili a me nā mana. E ʻoluʻolu e hoʻohui pū .col-form-labeli kāu <label>s no laila e kū pololei lākou me kā lākou mau mana pili.

I kekahi manawa, pono paha ʻoe e hoʻohana i ka margin a i ʻole nā ​​​​mea hana padding e hana i kēlā alignment kūpono āu e pono ai. No ka laʻana, ua wehe padding-topmākou i ka lepili hoʻokomo lekiō i hoʻopaʻa ʻia no ka hoʻopololei maikaʻi ʻana i ka pae kikokikona.

Lekiō
html
<form>
  <div class="row mb-3">
    <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">
    </div>
  </div>
  <div class="row mb-3">
    <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">
    </div>
  </div>
  <fieldset class="row mb-3">
    <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>
  </fieldset>
  <div class="row mb-3">
    <div class="col-sm-10 offset-sm-2">
      <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>
  <button type="submit" class="btn btn-primary">Sign in</button>
</form>

ʻO ka nui o ka lepili ʻano horizontal

E hoʻohana .col-form-label-sma .col-form-label-lgi kāu <label>s a i ʻole <legend>e hahai pono i ka nui o .form-control-lga me .form-control-sm.

html
<div class="row mb-3">
  <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="row mb-3">
  <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="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>

Ka nui o ke kolamu

E like me ka mea i hōʻike ʻia ma nā hiʻohiʻona mua, ʻae kā mākou ʻōnaehana grid iā ʻoe e kau i kekahi helu o nā .cols i loko o kahi .row. E hoʻokaʻawale like lākou i ka laulā i loaʻa ma waena o lākou. Hiki paha iā ʻoe ke koho i kahi ʻāpana o kāu mau kolamu e hoʻonui a i ʻole ka liʻiliʻi o ka hakahaka, a ʻo ke koena .cole hoʻokaʻawale like i ke koena, me nā papa kolamu kikoʻī e like me .col-sm-7.

html
<div class="row g-3">
  <div class="col-sm-7">
    <input type="text" class="form-control" placeholder="City" aria-label="City">
  </div>
  <div class="col-sm">
    <input type="text" class="form-control" placeholder="State" aria-label="State">
  </div>
  <div class="col-sm">
    <input type="text" class="form-control" placeholder="Zip" aria-label="Zip">
  </div>
</div>

Ka nui-aunoa

Ke hoʻohana nei ka laʻana ma lalo nei i kahi pono flexbox e hoʻokaʻawale i nā ʻike a me nā hoʻololi .coli .col-autohiki i kāu kolamu ke lawe i ka nui o ka nui e like me ka mea e pono ai. E hoʻohui i kekahi ʻano ʻē aʻe, ʻo ka nui o ke kolamu ma muli o nā mea i loko.

@
html
<form class="row gy-2 gx-3 align-items-center">
  <div class="col-auto">
    <label class="visually-hidden" for="autoSizingInput">Name</label>
    <input type="text" class="form-control" id="autoSizingInput" placeholder="Jane Doe">
  </div>
  <div class="col-auto">
    <label class="visually-hidden" for="autoSizingInputGroup">Username</label>
    <div class="input-group">
      <div class="input-group-text">@</div>
      <input type="text" class="form-control" id="autoSizingInputGroup" placeholder="Username">
    </div>
  </div>
  <div class="col-auto">
    <label class="visually-hidden" for="autoSizingSelect">Preference</label>
    <select class="form-select" id="autoSizingSelect">
      <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">
    <div class="form-check">
      <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">Submit</button>
  </div>
</form>

Hiki iā ʻoe ke hoʻohui hou i kēlā me nā papa kolamu nui.

@
html
<form class="row gx-3 gy-2 align-items-center">
  <div class="col-sm-3">
    <label class="visually-hidden" for="specificSizeInputName">Name</label>
    <input type="text" class="form-control" id="specificSizeInputName" placeholder="Jane Doe">
  </div>
  <div class="col-sm-3">
    <label class="visually-hidden" for="specificSizeInputGroupUsername">Username</label>
    <div class="input-group">
      <div class="input-group-text">@</div>
      <input type="text" class="form-control" id="specificSizeInputGroupUsername" placeholder="Username">
    </div>
  </div>
  <div class="col-sm-3">
    <label class="visually-hidden" for="specificSizeSelect">Preference</label>
    <select class="form-select" id="specificSizeSelect">
      <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">
    <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">
    <button type="submit" class="btn btn-primary">Submit</button>
  </div>
</form>

Nā palapala laina

E hoʻohana i nā .row-cols-*papa no ka hana ʻana i nā hoʻolālā hoʻohāhā pane. Ma ka hoʻohui ʻana i nā papa hoʻololi ʻauwai , e loaʻa iā mākou nā auwai ma nā ʻaoʻao ākea a me ke kūpaʻa. Ma nā puka ʻike paʻa lima liʻiliʻi, nā mea .col-12kōkua e hoʻopaʻa i nā mana palapala a me nā mea hou aku. Hoʻopili .align-items-centerka mea i nā ʻano ʻano i ka waena, e hana pono i ka .form-checkalign.

@
html
<form class="row row-cols-lg-auto g-3 align-items-center">
  <div class="col-12">
    <label class="visually-hidden" for="inlineFormInputGroupUsername">Username</label>
    <div class="input-group">
      <div class="input-group-text">@</div>
      <input type="text" class="form-control" id="inlineFormInputGroupUsername" placeholder="Username">
    </div>
  </div>

  <div class="col-12">
    <label class="visually-hidden" for="inlineFormSelectPref">Preference</label>
    <select class="form-select" id="inlineFormSelectPref">
      <option selected>Choose...</option>
      <option value="1">One</option>
      <option value="2">Two</option>
      <option value="3">Three</option>
    </select>
  </div>

  <div class="col-12">
    <div class="form-check">
      <input class="form-check-input" type="checkbox" id="inlineFormCheck">
      <label class="form-check-label" for="inlineFormCheck">
        Remember me
      </label>
    </div>
  </div>

  <div class="col-12">
    <button type="submit" class="btn btn-primary">Submit</button>
  </div>
</form>