Txheej txheem cej luam

Tau txais qhov qis qis ntawm cov khoom tseem ceeb ntawm Bootstrap cov txheej txheem, suav nrog peb txoj hauv kev kom zoo dua, nrawm dua, txhim kho lub vev xaib kom muaj zog.

HTML5 doctype

Bootstrap ua rau siv qee cov ntsiab lus HTML thiab CSS cov khoom uas yuav tsum tau siv HTML5 doctype. suav nrog nws thaum pib ntawm tag nrho koj cov haujlwm.

<!DOCTYPE html>
<html lang="en">
  ...
</html>

Mobile ua ntej

Nrog Bootstrap 2, peb ntxiv cov kev xaiv mobile tus phooj ywg zoo rau qhov tseem ceeb ntawm lub moj khaum. Nrog Bootstrap 3, peb tau rov sau qhov project kom ua tus phooj ywg mobile txij thaum pib. Es tsis txhob ntxiv rau cov kev xaiv mobile, lawv tau ci rau hauv qhov tseem ceeb. Qhov tseeb, Bootstrap yog mobile ua ntej . Cov qauv txawb thawj zaug tuaj yeem pom thoob plaws hauv lub tsev qiv ntawv tag nrho tsis yog hauv cov ntaub ntawv cais.

Txhawm rau kom ua tiav qhov zoo thiab kov zooming, ntxiv qhov pom qhov pom meta tag rau koj <head>.

<meta name="viewport" content="width=device-width, initial-scale=1">

Koj tuaj yeem lov tes taw lub peev xwm zooming ntawm cov khoom siv txawb los ntawm kev ntxiv user-scalable=norau qhov pom pom meta tag. Qhov no disables zooming, txhais tau hais tias cov neeg siv tsuas muaj peev xwm mus scroll, thiab ua rau koj qhov chaw zoo li me ntsis ntau dua li ib txwm daim ntawv thov. Zuag qhia tag nrho, peb tsis pom zoo qhov no rau txhua qhov chaw, yog li siv ceev faj!

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

Bootstrap teeb tsa lub ntiaj teb cov zaub, typography, thiab txuas cov qauv. Tshwj xeeb, peb:

  • Teem background-color: #fff;rau ntawmbody
  • Siv cov @font-family-base, @font-size-base, thiab @line-height-basecov cwj pwm ua peb lub hauv paus typographic
  • Teem lub ntiaj teb txuas xim ntawm @link-colorthiab siv qhov txuas hauv qab tsuas yog rau:hover

Cov style no tuaj yeem pom hauv scaffolding.less.

Normalize.css

Rau kev txhim kho tus ntoo khaub lig-browser rendering, peb siv Normalize.css , ib qhov project los ntawm Nicolas Gallagher thiab Jonathan Neal .

Ntim

Bootstrap yuav tsum muaj cov khoom siv los qhwv cov ntsiab lus ntawm qhov chaw thiab tsev peb cov kab sib chaws. Koj tuaj yeem xaiv ib qho ntawm ob lub thawv los siv hauv koj cov haujlwm. Nco ntsoov tias, vim paddingthiab ntau dua, ob lub thawv tsis yog zesable.

Siv .containerrau lub teb ruaj ruaj ntim ntim.

<div class="container">
  ...
</div>

Siv .container-fluidrau lub thawv dav dav, hla tag nrho qhov dav ntawm koj qhov chaw saib.

<div class="container-fluid">
  ...
</div>

Daim phiaj system

Bootstrap suav nrog cov lus teb, mobile thawj cov kab sib chaws ua kua dej uas tsim nyog teev txog 12 kab raws li lub cuab yeej lossis qhov chaw saib qhov loj tuaj. Nws suav nrog cov chav kawm ua ntej rau kev xaiv layout yooj yim, nrog rau cov mixins muaj zog rau kev tsim ntau qhov kev sib txuas lus .

Taw qhia

Grid systems yog siv los tsim cov nplooj ntawv layouts los ntawm cov kab thiab kab uas nyob hauv koj cov ntsiab lus. Nov yog yuav ua li cas Bootstrap grid system ua haujlwm:

  • Cov kab yuav tsum tau muab tso rau hauv ib qho .container(taw-dav) lossis .container-fluid(tag nrho-dav) rau kev sib dhos kom zoo thiab padding.
  • Siv kab los tsim cov kab kab rov tav ntawm kab.
  • Cov ntsiab lus yuav tsum tau muab tso rau hauv kab, thiab tsuas yog kab yuav yog cov menyuam yaus ntawm kab.
  • Cov chav kawm ntawv predefined grid zoo li .rowthiab .col-xs-4muaj rau kev ua cov phiaj xwm sai sai. Tsawg mixins kuj tuaj yeem siv rau ntau qhov layouts semantic.
  • Kem tsim gutters (nruab nrab ntawm kab lus) ntawm padding. Qhov padding yog offset nyob rau hauv kab rau thawj thiab kawg kem ntawm qhov tsis zoo margin ntawm .rows.
  • Cov npoo tsis zoo yog vim li cas cov piv txwv hauv qab no yog outdented. Nws yog li ntawd cov ntsiab lus nyob rau hauv kab sib chaws yog lined nrog cov ntsiab lus uas tsis yog kab sib chaws.
  • Daim phiaj kab yog tsim los ntawm kev qhia tus naj npawb ntawm kaum ob kab uas koj xav kom ncua. Piv txwv li, peb kab sib npaug yuav siv peb .col-xs-4.
  • Yog tias ntau tshaj 12 kab tau muab tso rau hauv ib kab, txhua pawg ntawm kab ntxiv yuav, raws li ib chav tsev, qhwv rau ib kab tshiab.
  • Cov chav kawm kab sib chaws siv rau cov khoom siv nrog qhov dav dav dav dua lossis sib npaug ntawm qhov sib npaug ntawm qhov ntau thiab tsawg, thiab hla cov chav kawm ntawv phiaj xwm ntawm cov khoom siv me me. Yog li ntawd, piv txwv li siv ib .col-md-*chav kawm rau ib lub caij yuav tsis tsuas yog cuam tshuam rau nws cov styling ntawm cov khoom siv nruab nrab tab sis kuj ntawm cov khoom siv loj yog tias tsis muaj .col-lg-*chav kawm.

Saib rau cov piv txwv rau kev siv cov ntsiab cai no rau koj cov cai.

Media lus nug

Peb siv cov lus nug hauv qab no hauv peb cov ntaub ntawv tsawg los tsim cov ntsiab lus tseem ceeb hauv peb cov kab sib chaws.

/* Extra small devices (phones, less than 768px) */
/* No media query since this is the default in Bootstrap */

/* Small devices (tablets, 768px and up) */
@media (min-width: @screen-sm-min) { ... }

/* Medium devices (desktops, 992px and up) */
@media (min-width: @screen-md-min) { ... }

/* Large devices (large desktops, 1200px and up) */
@media (min-width: @screen-lg-min) { ... }

Peb qee zaus nthuav dav ntawm cov lus nug xov xwm no kom suav max-widthnrog txwv CSS rau cov khoom siv nqaim.

@media (max-width: @screen-xs-max) { ... }
@media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { ... }
@media (min-width: @screen-md-min) and (max-width: @screen-md-max) { ... }
@media (min-width: @screen-lg-min) { ... }

Grid xaiv

Saib seb yam ntawm Bootstrap kab sib chaws ua haujlwm li cas hla ntau yam khoom siv nrog lub rooj ua ke.

Cov khoom siv me me ntxiv Xov tooj (<768px) Cov ntsiav tshuaj me me (≥768px) Cov khoom siv nruab nrab Desktops (≥992px) Cov khoom siv loj Desktops (≥1200px)
Grid cwj pwm Kab rov tav txhua lub sijhawm Collapsed los pib, kab rov tav saum lub breakpoints
Thawv dav Tsis muaj (auto) 7 50px 9 70px 1 170px
Chav ua ntej .col-xs- .col-sm- .col-md- .col-lg-
# ntawm kab 12
Kab dav Auto ~ 62 px ~ 81 px ~ 97 px
Gutter dav 30px (15px ntawm txhua sab ntawm kab)
Nestable Yog lawm
Offsets Yog lawm
Kem xaj Yog lawm

Piv txwv li: Stacked-to-horizontal

Siv ib txheej ntawm .col-md-*kab sib chaws, koj tuaj yeem tsim cov kab sib chaws yooj yim uas pib tawm ntawm cov khoom siv txawb thiab cov ntsiav tshuaj (qhov ntxiv me me rau me me) ua ntej ua kab rov tav ntawm desktop (nruab nrab) cov khoom siv. Muab kab kab kab rau hauv ib qho twg .row.

.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-8
.col-md-4
.col-md-4
.col-md-4
.col-md-4
.col-md-6
.col-md-6
<div class="row">
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
</div>
<div class="row">
  <div class="col-md-8">.col-md-8</div>
  <div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
  <div class="col-md-4">.col-md-4</div>
  <div class="col-md-4">.col-md-4</div>
  <div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
  <div class="col-md-6">.col-md-6</div>
  <div class="col-md-6">.col-md-6</div>
</div>

Piv txwv li: Lub thawv ntim dej

Tig txhua qhov dav-dav-daim phiaj layout rau hauv qhov dav-dav layout los ntawm kev hloov koj sab nraud .containermus rau .container-fluid.

<div class="container-fluid">
  <div class="row">
    ...
  </div>
</div>

Piv txwv li: Mobile thiab desktop

Tsis xav kom koj cov kab ke yooj yim hauv cov khoom siv me me? Siv cov chav kawm me me thiab nruab nrab cov khoom siv ntxiv los ntawm kev ntxiv .col-xs-* .col-md-*rau koj cov kab. Saib cov piv txwv hauv qab no kom paub ntau ntxiv txog qhov nws ua haujlwm li cas.

txz -> ../All-xs-12 .col-md-8
.col-xs-6 .col-md-4
.col-xs-6 .col-md-4
.col-xs-6 .col-md-4
.col-xs-6 .col-md-4
.col-xs-6
.col-xs-6
<!-- Stack the columns on mobile by making one full-width and the other half-width -->
<div class="row">
  <div class="col-xs-12 col-md-8">.col-xs-12 .col-md-8</div>
  <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>

<!-- Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop -->
<div class="row">
  <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
  <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
  <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>

<!-- Columns are always 50% wide, on mobile and desktop -->
<div class="row">
  <div class="col-xs-6">.col-xs-6</div>
  <div class="col-xs-6">.col-xs-6</div>
</div>

Piv txwv li: txawb, ntsiav tshuaj, desktop

Ua raws li qhov piv txwv yav dhau los los ntawm kev tsim cov dynamic thiab muaj zog layouts nrog cov .col-sm-*chav kawm ntsiav tshuaj.

.col-xs-12 .col-sm-6 .col-md-8
.col-xs-6 .col-md-4
.col-xs-6 .col-sm-4
.col-xs-6 .col-sm-4
.col-xs-6 .col-sm-4
<div class="row">
  <div class="col-xs-12 col-sm-6 col-md-8">.col-xs-12 .col-sm-6 .col-md-8</div>
  <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>
<div class="row">
  <div class="col-xs-6 col-sm-4">.col-xs-6 .col-sm-4</div>
  <div class="col-xs-6 col-sm-4">.col-xs-6 .col-sm-4</div>
  <!-- Optional: clear the XS cols if their content doesn't match in height -->
  <div class="clearfix visible-xs-block"></div>
  <div class="col-xs-6 col-sm-4">.col-xs-6 .col-sm-4</div>
</div>

Piv txwv: Kem wrapping

Yog tias ntau tshaj 12 kab tau muab tso rau hauv ib kab, txhua pawg ntawm kab ntxiv yuav, raws li ib chav tsev, qhwv rau ib kab tshiab.

.col-xs-9
.col-xs-4
Txij li thaum 9 + 4 = 13 > 12, no 4-kem-div dav tau qhwv rau ib kab tshiab raws li ib qho kev sib txuas.
.col-xs-6
Cov kab tom ntej txuas ntxiv raws kab tshiab.
<div class="row">
  <div class="col-xs-9">.col-xs-9</div>
  <div class="col-xs-4">.col-xs-4<br>Since 9 + 4 = 13 &gt; 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.</div>
  <div class="col-xs-6">.col-xs-6<br>Subsequent columns continue along the new line.</div>
</div>

Teb kab rov pib dua

Nrog rau plaub theem ntawm daim phiaj muaj koj yuav tsum tau khiav mus rau hauv cov teeb meem qhov twg, ntawm qee qhov breakpoints, koj cov kab ntawv tsis meej heev vim tias ib qho siab dua lwm qhov. Txhawm rau kho qhov ntawd, siv qhov sib xyaw ua ke ntawm ib qho .clearfixthiab peb cov chav kawm siv hluav taws xob ua haujlwm .

.col-xs-6 .col-sm-3
Resize your viewport or check it out on your phone for example.
.col-xs-6 .col-sm-3
.col-xs-6 .col-sm-3
.col-xs-6 .col-sm-3
<div class="row">
  <div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
  <div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>

  <!-- Add the extra clearfix for only the required viewport -->
  <div class="clearfix visible-xs-block"></div>

  <div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
  <div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
</div>

Ntxiv nrog rau kev tshem tawm kab ntawm cov ntsiab lus teb, koj yuav tsum tau rov pib dua offsets, thawb, lossis rub . Saib qhov no hauv kev nqis tes ua hauv daim phiaj piv txwv .

<div class="row">
  <div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
  <div class="col-sm-5 col-sm-offset-2 col-md-6 col-md-offset-0">.col-sm-5 .col-sm-offset-2 .col-md-6 .col-md-offset-0</div>
</div>

<div class="row">
  <div class="col-sm-6 col-md-5 col-lg-6">.col-sm-6 .col-md-5 .col-lg-6</div>
  <div class="col-sm-6 col-md-5 col-md-offset-2 col-lg-6 col-lg-offset-0">.col-sm-6 .col-md-5 .col-md-offset-2 .col-lg-6 .col-lg-offset-0</div>
</div>

Offsetting kab

Txav cov kab mus rau sab xis siv .col-md-offset-*cov chav kawm. Cov chav kawm no nce sab laug ntawm ib kab los ntawm *kab. Piv txwv li, .col-md-offset-4txav .col-md-4dhau plaub kab.

.col-md-4
.col-md-4 .col-md-offset-4
.col-md-3 .col-md-offset-3
.col-md-3 .col-md-offset-3
.col-md-6 .col-md-offset-3
<div class="row">
  <div class="col-md-4">.col-md-4</div>
  <div class="col-md-4 col-md-offset-4">.col-md-4 .col-md-offset-4</div>
</div>
<div class="row">
  <div class="col-md-3 col-md-offset-3">.col-md-3 .col-md-offset-3</div>
  <div class="col-md-3 col-md-offset-3">.col-md-3 .col-md-offset-3</div>
</div>
<div class="row">
  <div class="col-md-6 col-md-offset-3">.col-md-6 .col-md-offset-3</div>
</div>

Koj tseem tuaj yeem override offsets los ntawm cov kab qis qis nrog .col-*-offset-0cov chav kawm.

<div class="row">
  <div class="col-xs-6 col-sm-4">
  </div>
  <div class="col-xs-6 col-sm-4">
  </div>
  <div class="col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-0">
  </div>
</div>

Zes kab

Txhawm rau zes koj cov ntsiab lus nrog daim phiaj xwm txheej, ntxiv ib qho tshiab .rowthiab cov .col-sm-*kab hauv kab uas twb muaj lawm .col-sm-*. Nested kab yuav tsum muaj cov kab ke uas ntxiv txog 12 lossis tsawg dua (nws tsis tas yuav tsum tau siv tag nrho 12 kab muaj).

Qib 1: .col-sm-9
Qib 2: .col-xs-8 .col-sm-6
Qib 2: .col-xs-4 .col-sm-6
<div class="row">
  <div class="col-sm-9">
    Level 1: .col-sm-9
    <div class="row">
      <div class="col-xs-8 col-sm-6">
        Level 2: .col-xs-8 .col-sm-6
      </div>
      <div class="col-xs-4 col-sm-6">
        Level 2: .col-xs-4 .col-sm-6
      </div>
    </div>
  </div>
</div>

Kem xaj

Yooj yim hloov qhov kev txiav txim ntawm peb cov kab sib txuas ua ke nrog .col-md-push-*thiab .col-md-pull-*hloov cov chav kawm.

.col-md-9 .col-md-push-3
txz | | |-- .col-md-3 .col-md-pull-9
<div class="row">
  <div class="col-md-9 col-md-push-3">.col-md-9 .col-md-push-3</div>
  <div class="col-md-3 col-md-pull-9">.col-md-3 .col-md-pull-9</div>
</div>

Tsawg mixins thiab variables

Ntxiv rau cov chav kawm prebuilt grids rau cov layouts ceev, Bootstrap suav nrog Less variables thiab mixins kom sai tsim koj tus kheej yooj yim, semantic layouts.

Hloov pauv

Cov kev sib txawv txiav txim seb tus naj npawb ntawm kab, qhov dav ntawm lub qhov dej, thiab cov lus nug xov xwm ntawm qhov uas yuav pib cov kab ke. Peb siv cov no los tsim cov chav kawm ntawv teev tseg ua ntej sau tseg saum toj no, nrog rau cov kev cai mixins teev hauv qab no.

@grid-columns:              12;
@grid-gutter-width:         30px;
@grid-float-breakpoint:     768px;

Mixins

Mixins yog siv ua ke nrog cov kab sib chaws sib txawv los tsim cov CSS semantic rau ib tus kab sib chaws.

// Creates a wrapper for a series of columns
.make-row(@gutter: @grid-gutter-width) {
  // Then clear the floated columns
  .clearfix();

  @media (min-width: @screen-sm-min) {
    margin-left:  (@gutter / -2);
    margin-right: (@gutter / -2);
  }

  // Negative margin nested rows out to align the content of columns
  .row {
    margin-left:  (@gutter / -2);
    margin-right: (@gutter / -2);
  }
}

// Generate the extra small columns
.make-xs-column(@columns; @gutter: @grid-gutter-width) {
  position: relative;
  // Prevent columns from collapsing when empty
  min-height: 1px;
  // Inner gutter via padding
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);

  // Calculate width based on number of columns available
  @media (min-width: @grid-float-breakpoint) {
    float: left;
    width: percentage((@columns / @grid-columns));
  }
}

// Generate the small columns
.make-sm-column(@columns; @gutter: @grid-gutter-width) {
  position: relative;
  // Prevent columns from collapsing when empty
  min-height: 1px;
  // Inner gutter via padding
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);

  // Calculate width based on number of columns available
  @media (min-width: @screen-sm-min) {
    float: left;
    width: percentage((@columns / @grid-columns));
  }
}

// Generate the small column offsets
.make-sm-column-offset(@columns) {
  @media (min-width: @screen-sm-min) {
    margin-left: percentage((@columns / @grid-columns));
  }
}
.make-sm-column-push(@columns) {
  @media (min-width: @screen-sm-min) {
    left: percentage((@columns / @grid-columns));
  }
}
.make-sm-column-pull(@columns) {
  @media (min-width: @screen-sm-min) {
    right: percentage((@columns / @grid-columns));
  }
}

// Generate the medium columns
.make-md-column(@columns; @gutter: @grid-gutter-width) {
  position: relative;
  // Prevent columns from collapsing when empty
  min-height: 1px;
  // Inner gutter via padding
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);

  // Calculate width based on number of columns available
  @media (min-width: @screen-md-min) {
    float: left;
    width: percentage((@columns / @grid-columns));
  }
}

// Generate the medium column offsets
.make-md-column-offset(@columns) {
  @media (min-width: @screen-md-min) {
    margin-left: percentage((@columns / @grid-columns));
  }
}
.make-md-column-push(@columns) {
  @media (min-width: @screen-md-min) {
    left: percentage((@columns / @grid-columns));
  }
}
.make-md-column-pull(@columns) {
  @media (min-width: @screen-md-min) {
    right: percentage((@columns / @grid-columns));
  }
}

// Generate the large columns
.make-lg-column(@columns; @gutter: @grid-gutter-width) {
  position: relative;
  // Prevent columns from collapsing when empty
  min-height: 1px;
  // Inner gutter via padding
  padding-left:  (@gutter / 2);
  padding-right: (@gutter / 2);

  // Calculate width based on number of columns available
  @media (min-width: @screen-lg-min) {
    float: left;
    width: percentage((@columns / @grid-columns));
  }
}

// Generate the large column offsets
.make-lg-column-offset(@columns) {
  @media (min-width: @screen-lg-min) {
    margin-left: percentage((@columns / @grid-columns));
  }
}
.make-lg-column-push(@columns) {
  @media (min-width: @screen-lg-min) {
    left: percentage((@columns / @grid-columns));
  }
}
.make-lg-column-pull(@columns) {
  @media (min-width: @screen-lg-min) {
    right: percentage((@columns / @grid-columns));
  }
}

Piv txwv kev siv

Koj tuaj yeem hloov kho qhov hloov pauv rau koj tus kheej cov txiaj ntsig kev cai, lossis tsuas yog siv cov mixins nrog lawv cov nqi qub. Ntawm no yog ib qho piv txwv ntawm kev siv lub neej ntawd teeb tsa los tsim ob kab layout nrog qhov sib txawv ntawm.

.wrapper {
  .make-row();
}
.content-main {
  .make-lg-column(8);
}
.content-secondary {
  .make-lg-column(3);
  .make-lg-column-offset(1);
}
<div class="wrapper">
  <div class="content-main">...</div>
  <div class="content-secondary">...</div>
</div>

Typography

Cov ntsiab lus

Tag nrho cov ntsiab lus HTML, <h1>dhau los <h6>, muaj. .h1los ntawm .h6cov chav kawm kuj muaj, rau thaum koj xav kom phim cov font styling ntawm ib nqe lus tab sis tseem xav kom koj cov ntawv tso tawm kom pom hauv kab.

h 1. Bootstrap taub hau

ib 36px

h 2. Bootstrap taub hau

ib 30px

h 3. Bootstrap taub hau

ib 24px

h 4. Bootstrap taub hau

ib 18px
h 5. Bootstrap taub hau
ib 14px
h 6. Bootstrap taub hau
ib 12px
<h1>h1. Bootstrap heading</h1>
<h2>h2. Bootstrap heading</h2>
<h3>h3. Bootstrap heading</h3>
<h4>h4. Bootstrap heading</h4>
<h5>h5. Bootstrap heading</h5>
<h6>h6. Bootstrap heading</h6>

Tsim cov ntawv sib dua, cov ntawv thib ob hauv txhua nqe lus nrog cov <small>ntawv sau lossis cov .smallchav kawm.

h 1. Bootstrap heading Secondary text

h 2. Bootstrap heading Secondary text

h 3. Bootstrap heading Secondary text

h 4. Bootstrap heading Secondary text

h 5. Bootstrap heading Secondary text
h 6. Bootstrap heading Secondary text
<h1>h1. Bootstrap heading <small>Secondary text</small></h1>
<h2>h2. Bootstrap heading <small>Secondary text</small></h2>
<h3>h3. Bootstrap heading <small>Secondary text</small></h3>
<h4>h4. Bootstrap heading <small>Secondary text</small></h4>
<h5>h5. Bootstrap heading <small>Secondary text</small></h5>
<h6>h6. Bootstrap heading <small>Secondary text</small></h6>

Lub cev luam tawm

Bootstrap lub ntiaj teb no default font-sizeyog 14px , nrog ib tug line-heightntawm 1.428 . Qhov no yog siv rau <body>tag nrho cov kab lus. Tsis tas li ntawd, <p>(cov kab lus) tau txais cov kab hauv qab ntawm ib nrab ntawm lawv cov kab-qhov siab (10px los ntawm lub neej ntawd).

Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam id dolor id nibh ultricies vehicula.

Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec ullamcorper nulla non metus auctor fringilla. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec ullamcorper nulla non metus auctor fringilla.

Maecenas sed diam eget risus varius blandit zaum amet tsis magna. Donec id elit non mi porta gravida at eget metus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.

<p>...</p>

Lead lub cev luam

Ua ib kab lus sawv tawm los ntawm kev ntxiv .lead.

Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, nws tsis yog commodo luctus.

<p class="lead">...</p>

Ua nrog Tsawg

Qhov ntsuas typographic yog nyob ntawm ob qhov sib txawv tsawg dua hauv cov variables.less : @font-size-basethiab @line-height-base. Thawj yog lub hauv paus font-loj siv thoob plaws thiab qhov thib ob yog lub hauv paus kab-qhov siab. Peb siv cov kev hloov pauv no thiab qee qhov lej yooj yim los tsim cov npoo, paddings, thiab kab-qhov siab ntawm txhua yam peb hom thiab ntau dua. Customize lawv thiab Bootstrap adapts.

Cov ntsiab lus hauv kab ntawv

Cov ntawv cim

Rau qhov tseem ceeb ntawm cov ntawv sau vim nws qhov cuam tshuam hauv lwm cov ntsiab lus, siv lub <mark>cim npe.

Koj tuaj yeem siv lub cim cim rautseem ceebntawv nyeem.

You can use the mark tag to <mark>highlight</mark> text.

Deleted ntawv nyeem

Txhawm rau qhia cov ntawv blocks uas tau muab tshem tawm siv lub <del>cim npe.

Cov kab ntawv no yog txhais tau tias yuav raug kho raws li cov ntawv deleted.

<del>This line of text is meant to be treated as deleted text.</del>

Strikethrough ntawv nyeem

Txhawm rau qhia cov ntawv blocks uas tsis muaj feem cuam tshuam siv lub <s>cim npe.

Cov kab ntawv no txhais tau tias yuav raug kho raws li qhov tsis raug lawm.

<s>This line of text is meant to be treated as no longer accurate.</s>

Ntxig ntawv nyeem

Rau kev qhia ntxiv rau cov ntaub ntawv siv lub <ins>cim npe.

Cov kab ntawv no yog txhais tau tias yuav raug kho raws li qhov ntxiv rau daim ntawv.

<ins>This line of text is meant to be treated as an addition to the document.</ins>

Cov ntawv hauv qab

Txhawm rau kos kab ntawv siv lub <u>cim.

Cov kab ntawv no yuav ua raws li hauv qab

<u>This line of text will render as underlined</u>

Ua kom siv HTML's default emphasis tags nrog cov qauv hnyav.

Cov ntawv me me

Txhawm rau tshem tawm cov ntsiab lus hauv kab lossis thaiv cov ntawv, siv lub <small>cim los teeb tsa cov ntawv ntawm 85% qhov loj ntawm niam txiv. Cov ntsiab lus tau txais lawv tus kheej font-sizerau cov ntsiab lus nested <small>.

Koj tuaj yeem hloov pauv siv lub ntsiab lus inline nrog .smallrau qhov chaw <small>.

Cov kab ntawv no yog txhais tau tias yuav tsum tau kho raws li kev luam zoo.

<small>This line of text is meant to be treated as fine print.</small>

Ua siab loj

Rau kev hais txog ib qho snippet ntawm cov ntawv nrog hnyav font-qhov hnyav.

Cov snippet hauv qab no yog rendered ua bold text .

<strong>rendered as bold text</strong>

Italics

Rau kev hais txog ib ntu ntawm cov ntawv nrog italics.

Cov kab lus hauv qab no tau muab ua cov ntawv italicized .

<em>rendered as italicized text</em>

Hloov cov ntsiab lus

Txaus siab rau siv <b>thiab <i>hauv HTML5. <b>yog txhais tau hais tias tseem ceeb cov lus lossis kab lus yam tsis muaj qhov tseem ceeb ntxiv thaum <i>feem ntau yog rau lub suab, cov lus qhia, thiab lwm yam.

Cov chav kawm Alignment

Yooj yim realign cov ntawv rau cov khoom nrog cov chav kawm ntawv nyeem.

Left aligned text.

Center aligned ntawv nyeem.

Txoj cai dlhos ntawv.

Cov ntawv tseeb.

Tsis qhwv ntawv.

<p class="text-left">Left aligned text.</p>
<p class="text-center">Center aligned text.</p>
<p class="text-right">Right aligned text.</p>
<p class="text-justify">Justified text.</p>
<p class="text-nowrap">No wrap text.</p>

Cov chav kawm hloov pauv

Hloov cov ntawv hauv cov khoom nrog cov chav kawm ntawv sau ntawv.

Cov ntawv qis.

Uppercased ntawv nyeem.

Cov ntawv loj.

<p class="text-lowercase">Lowercased text.</p>
<p class="text-uppercase">Uppercased text.</p>
<p class="text-capitalize">Capitalized text.</p>

Cov ntawv luv

Stylized siv HTML lub <abbr>ntsiab lus rau cov ntawv luv thiab cov ntawv sau los qhia qhov nthuav dav ntawm hover. Cov ntawv luv luv nrog tus titlecwj pwm muaj lub teeb pom hauv qab ciam teb thiab tus cursor pab ntawm hover, muab cov ntsiab lus ntxiv ntawm hover thiab rau cov neeg siv cov cuab yeej pab.

Cov ntawv luv luv

Lub ntsiab lus ntawm lo lus attribute yog attr .

<abbr title="attribute">attr</abbr>

Initialism

Ntxiv .initialismrau cov ntawv luv rau me me font-loj.

HTML yog qhov zoo tshaj plaws txij li lub khob cij hlais.

<abbr title="HyperText Markup Language" class="initialism">HTML</abbr>

Chaw nyob

Muab cov ntaub ntawv tiv tauj tam sim no rau cov poj koob yawm txwv ze tshaj plaws lossis tag nrho lub cev ua haujlwm. Khaws formatting los ntawm kev xaus tag nrho cov kab nrog <br>.

Twitter, Inc.
1355 Market Street, Suite 900
San Francisco, CA 94103
P: (123) 456-7890
Lub Npe Lub Npe
[email protected]
<address>
  <strong>Twitter, Inc.</strong><br>
  1355 Market Street, Suite 900<br>
  San Francisco, CA 94103<br>
  <abbr title="Phone">P:</abbr> (123) 456-7890
</address>

<address>
  <strong>Full Name</strong><br>
  <a href="mailto:#">[email protected]</a>
</address>

Blockquotes

Rau quoting blocks ntawm cov ntsiab lus los ntawm lwm qhov chaw hauv koj cov ntaub ntawv.

Default blockquote

Qhwv <blockquote>ib ncig ntawm HTML raws li cov lus tsocai. Rau cov quotes ncaj, peb pom zoo ib <p>.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat ante.

<blockquote>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
</blockquote>

Blockquote xaiv

Cov qauv thiab cov ntsiab lus hloov pauv rau kev hloov pauv yooj yim ntawm tus qauv <blockquote>.

Sau npe qhov chaw

Ntxiv <footer>rau kev txheeb xyuas qhov chaw. Muab lub npe ntawm qhov chaw ua haujlwm hauv <cite>.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat ante.

Ib tug neeg nto moo nyob rau hauv Lub Npe Lub Npe
<blockquote>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
  <footer>Someone famous in <cite title="Source Title">Source Title</cite></footer>
</blockquote>

Hloov cov duab

Ntxiv .blockquote-reverserau ib qho blockquote nrog cov ntsiab lus ncaj nraim.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat ante.

Ib tug neeg nto moo nyob rau hauv Lub Npe Lub Npe
<blockquote class="blockquote-reverse">
  ...
</blockquote>

Cov npe

Unordered

Ib daim ntawv teev cov khoom uas qhov kev txiav txim tsis meej meej.

  • Lorem ipsum dolor sit amet
  • Consectetur adipiscing elit
  • Integer molestie lorem thiab massa
  • Facilisis nyob rau hauv pretium nisl aliquet
  • Nulla volutpat aliquam velit
    • Phasellus iaculis neque
    • Purus sodales ultricies
    • Vestibulum laoreet porttitor sem
    • Ac tristique libero volutpat ntawm
  • Faucibus porta lacus fringilla vel
  • Aenean zaum amet erat nunc
  • Eget porttitor lorem
<ul>
  <li>...</li>
</ul>

Txiav txim

Ib daim ntawv teev cov khoom uas qhov kev txiav txim tsis meej.

  1. Lorem ipsum dolor sit amet
  2. Consectetur adipiscing elit
  3. Integer molestie lorem thiab massa
  4. Facilisis nyob rau hauv pretium nisl aliquet
  5. Nulla volutpat aliquam velit
  6. Faucibus porta lacus fringilla vel
  7. Aenean zaum amet erat nunc
  8. Eget porttitor lorem
<ol>
  <li>...</li>
</ol>

Tsis zoo li

Tshem tawm lub neej ntawd list-stylethiab sab laug ntawm cov npe khoom (cov me nyuam tam sim ntawd). Qhov no tsuas yog siv rau cov menyuam yaus tam sim ntawd sau cov khoom , txhais tau tias koj yuav tsum tau ntxiv cov chav kawm rau cov npe nested ib yam nkaus.

  • Lorem ipsum dolor sit amet
  • Consectetur adipiscing elit
  • Integer molestie lorem thiab massa
  • Facilisis nyob rau hauv pretium nisl aliquet
  • Nulla volutpat aliquam velit
    • Phasellus iaculis neque
    • Purus sodales ultricies
    • Vestibulum laoreet porttitor sem
    • Ac tristique libero volutpat ntawm
  • Faucibus porta lacus fringilla vel
  • Aenean zaum amet erat nunc
  • Eget porttitor lorem
<ul class="list-unstyled">
  <li>...</li>
</ul>

Hauv kab

Muab tag nrho cov npe khoom rau ntawm ib kab nrog display: inline-block;thiab qee lub teeb padding.

  • Lorem ipsum
  • Phasellus iaculis
  • Nulla volutpat
<ul class="list-inline">
  <li>...</li>
</ul>

Kev piav qhia

Ib daim ntawv teev cov ntsiab lus nrog lawv cov lus piav qhia.

Cov npe piav qhia
Daim ntawv teev lus piav qhia zoo meej rau kev txhais cov ntsiab lus.
Euismod
Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.
Donec id elit non mi porta gravida at eget metus.
Malesuada porta
Etiam porta sem malesuada magna mollis euismod.
<dl>
  <dt>...</dt>
  <dd>...</dd>
</dl>

Kab rov tav piav qhia

Ua cov ntsiab lus thiab cov lus piav qhia nyob rau hauv <dl>kab ntawm ib sab. Pib tawm stacked zoo li default <dl>s, tab sis thaum lub navbar expands, ua li no.

Cov npe piav qhia
Daim ntawv teev lus piav qhia zoo meej rau kev txhais cov ntsiab lus.
Euismod
Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.
Donec id elit non mi porta gravida at eget metus.
Malesuada porta
Etiam porta sem malesuada magna mollis euismod.
Felis euismod semper eget lacinia
Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
<dl class="dl-horizontal">
  <dt>...</dt>
  <dd>...</dd>
</dl>

Auto-truncating

Kab rov tav cov npe piav qhia yuav txiav cov ntsiab lus uas ntev dhau los kom haum rau hauv kab laug sab nrog text-overflow. Nyob rau hauv nqaim viewports, lawv yuav hloov mus rau lub default stacked layout.

Code

Hauv kab

Qhwv inline snippet ntawm code nrog <code>.

Piv txwv li, <section>yuav tsum tau qhwv li inline.
For example, <code>&lt;section&gt;</code> should be wrapped as inline.

Cov neeg siv tswv yim

Siv qhov <kbd>taw qhia cov tswv yim uas feem ntau nkag los ntawm cov keyboard.

Txhawm rau hloov cov npe, ntaus cdua raws li lub npe ntawm cov npe.
Txhawm rau kho qhov chaw, nias ctrl + ,
To switch directories, type <kbd>cd</kbd> followed by the name of the directory.<br>
To edit settings, press <kbd><kbd>ctrl</kbd> + <kbd>,</kbd></kbd>

Basic thaiv

Siv <pre>rau ntau kab ntawm cov cai. Nco ntsoov khiav txhua lub kaum sab xis hauv cov cai rau kev ua kom raug.

<p>Simple text here...</p>
<pre>&lt;p&gt;Sample text here...&lt;/p&gt;</pre>

Koj tuaj yeem xaiv ntxiv cov .pre-scrollablechav kawm, uas yuav teeb tsa max-qhov siab ntawm 350px thiab muab y-axis scrollbar.

Hloov pauv

Txhawm rau qhia qhov hloov pauv siv lub <var>cim.

y = m x + b

<var>y</var> = <var>m</var><var>x</var> + <var>b</var>

Qauv tso zis

Rau kev qhia txog cov qauv tsim tawm los ntawm ib qho kev pab cuam siv lub <samp>cim npe.

Cov ntawv no yog tsim los kho raws li cov qauv tso tawm los ntawm lub khoos phis tawj program.

<samp>This text is meant to be treated as sample output from a computer program.</samp>

Rooj

Piv txwv

Rau qhov yooj yim styling - lub teeb padding thiab tsuas yog kab rov tav dividers - ntxiv cov hauv paus chav kawm .tablerau ib qho twg <table>. Tej zaum nws yuav zoo li tsis txaus ntseeg, tab sis muab kev siv dav dav ntawm cov ntxhuav rau lwm cov plugins xws li daim ntawv qhia hnub hli thiab cov hnub xaiv, peb tau xaiv cais peb cov kev cai cov lus.

Xaiv lub rooj kab lus.
# Lub Npe Lub Npe Tus neeg siv lub npe
1 Mark Otto @mdo
2 Yakhauj Thornton @fat
3 Larry noog @twitter
<table class="table">
  ...
</table>

Kab txaij

Siv .table-stripedlos ntxiv zebra-striping rau ib kab lus hauv <tbody>.

Cross-browser compatibility

Cov ntxhuav striped yog styled ntawm :nth-childCSS selector, uas tsis muaj nyob rau hauv Internet Explorer 8.

# Lub Npe Lub Npe Tus neeg siv lub npe
1 Mark Otto @mdo
2 Yakhauj Thornton @fat
3 Larry noog @twitter
<table class="table table-striped">
  ...
</table>

Ciam teb rooj

Ntxiv .table-borderedrau ciam teb rau txhua sab ntawm lub rooj thiab cov hlwb.

# Lub Npe Lub Npe Tus neeg siv lub npe
1 Mark Otto @mdo
2 Yakhauj Thornton @fat
3 Larry noog @twitter
<table class="table table-bordered">
  ...
</table>

Hover kab

Ntxiv .table-hoverlos pab kom lub xeev hover ntawm cov kab lus hauv ib <tbody>.

# Lub Npe Lub Npe Tus neeg siv lub npe
1 Mark Otto @mdo
2 Yakhauj Thornton @fat
3 Larry noog @twitter
<table class="table table-hover">
  ...
</table>

Condensed rooj

Ntxiv .table-condensedkom cov ntxhuav ntau compact los ntawm kev txiav cell padding nyob rau hauv ib nrab.

# Lub Npe Lub Npe Tus neeg siv lub npe
1 Mark Otto @mdo
2 Yakhauj Thornton @fat
3 Larry noog @twitter
<table class="table table-condensed">
  ...
</table>

Cov chav kawm ntawm cov ntsiab lus

Siv cov chav kawm contextual rau xim kab kab los yog ib lub hlwb.

Chav kawm Kev piav qhia
.active Siv cov xim hover rau ib kab lossis xovtooj
.success Qhia tau tias muaj kev vam meej lossis zoo
.info Qhia txog kev hloov pauv lossis kev nqis tes ua
.warning Qhia ceeb toom uas yuav xav tau kev saib xyuas
.danger Qhia txog qhov txaus ntshai lossis qhov ua tsis zoo
# Kab lus Kab lus Kab lus
1 Kem ntsiab lus Kem ntsiab lus Kem ntsiab lus
2 Kem ntsiab lus Kem ntsiab lus Kem ntsiab lus
3 Kem ntsiab lus Kem ntsiab lus Kem ntsiab lus
4 Kem ntsiab lus Kem ntsiab lus Kem ntsiab lus
5 Kem ntsiab lus Kem ntsiab lus Kem ntsiab lus
6 Kem ntsiab lus Kem ntsiab lus Kem ntsiab lus
7 Kem ntsiab lus Kem ntsiab lus Kem ntsiab lus
8 Kem ntsiab lus Kem ntsiab lus Kem ntsiab lus
9 Kem ntsiab lus Kem ntsiab lus Kem ntsiab lus
<!-- On rows -->
<tr class="active">...</tr>
<tr class="success">...</tr>
<tr class="warning">...</tr>
<tr class="danger">...</tr>
<tr class="info">...</tr>

<!-- On cells (`td` or `th`) -->
<tr>
  <td class="active">...</td>
  <td class="success">...</td>
  <td class="warning">...</td>
  <td class="danger">...</td>
  <td class="info">...</td>
</tr>

Qhia lub ntsiab lus rau kev pab technologies

Siv cov xim los ntxiv lub ntsiab lus rau kab lus lossis ib lub xov tooj ntawm tes tsuas yog muab qhov pom kev pom, uas yuav tsis raug xa mus rau cov neeg siv khoom siv thev naus laus zis - xws li cov ntawv nyeem. Xyuas kom meej tias cov ntaub ntawv qhia los ntawm cov xim yog pom tseeb los ntawm cov ntsiab lus nws tus kheej (cov ntawv pom nyob rau hauv cov kab lus / cell), los yog suav nrog lwm txoj kev, xws li cov ntawv ntxiv zais nrog cov .sr-onlychav kawm.

Cov lus teb

Tsim cov lus teb los ntawm kev qhwv ib qho twg .tablelos .table-responsiveua kom lawv nqes kab rov tav ntawm cov khoom siv me me (hauv qab 768px). Thaum saib ntawm txhua yam loj dua 768px dav, koj yuav tsis pom qhov txawv ntawm cov ntxhuav no.

Vertical clipping/truncation

Cov lus teb ua rau siv overflow-y: hidden, uas clips tawm cov ntsiab lus uas dhau mus rau hauv qab lossis sab saum toj ntawm lub rooj. Tshwj xeeb, qhov no tuaj yeem txiav tawm cov ntawv qhia zaub mov thiab lwm tus neeg thib peb widgets.

Firefox thiab fieldsets

Firefox muaj qee qhov ua tau txawv txawv teb qhov kev widthxav uas cuam tshuam nrog lub rooj teb. Qhov no tsis tuaj yeem overridden yam tsis muaj Firefox tshwj xeeb hack uas peb tsis muab hauv Bootstrap:

@-moz-document url-prefix() {
  fieldset { display: table-cell; }
}

Yog xav paub ntxiv, nyeem cov lus teb Stack Overflow .

# Cov kab lus Cov kab lus Cov kab lus Cov kab lus Cov kab lus Cov kab lus
1 Rooj cell Rooj cell Rooj cell Rooj cell Rooj cell Rooj cell
2 Rooj cell Rooj cell Rooj cell Rooj cell Rooj cell Rooj cell
3 Rooj cell Rooj cell Rooj cell Rooj cell Rooj cell Rooj cell
# Cov kab lus Cov kab lus Cov kab lus Cov kab lus Cov kab lus Cov kab lus
1 Rooj cell Rooj cell Rooj cell Rooj cell Rooj cell Rooj cell
2 Rooj cell Rooj cell Rooj cell Rooj cell Rooj cell Rooj cell
3 Rooj cell Rooj cell Rooj cell Rooj cell Rooj cell Rooj cell
<div class="table-responsive">
  <table class="table">
    ...
  </table>
</div>

Cov ntawv

Piv txwv

Tus kheej daim ntawv tswj tau txais qee qhov qauv thoob ntiaj teb. Tag nrho cov ntawv nyeem <input>, <textarea>, thiab <select>cov ntsiab lus nrog .form-controlraug teeb tsa los width: 100%;ntawm lub neej ntawd. Qhwv daim ntawv lo thiab tswj .form-groupkom zoo tshaj qhov sib nrug.

Piv txwv block-level pab ntawv nyeem ntawm no.

<form>
  <div class="form-group">
    <label for="exampleInputEmail1">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1">Password</label>
    <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
  </div>
  <div class="form-group">
    <label for="exampleInputFile">File input</label>
    <input type="file" id="exampleInputFile">
    <p class="help-block">Example block-level help text here.</p>
  </div>
  <div class="checkbox">
    <label>
      <input type="checkbox"> Check me out
    </label>
  </div>
  <button type="submit" class="btn btn-default">Submit</button>
</form>

Tsis txhob sib xyaw cov pab pawg nrog cov tswv yim pab pawg

Tsis txhob sib xyaw cov pab pawg ncaj qha nrog pab pawg nkag . Hloov chaw, zes pawg tswv yim sab hauv ntawm pawg ntawv.

Inline daim ntawv

Ntxiv .form-inlinerau koj daim ntawv (uas tsis tas yuav yog ib qho <form>) rau sab laug-kho thiab inline-block tswj. Qhov no tsuas yog siv rau cov ntawv hauv cov chaw saib uas muaj tsawg kawg yog 768px dav.

Tej zaum yuav xav tau kev cai dav

Inputs thiab xaiv tau width: 100%;siv los ntawm lub neej ntawd hauv Bootstrap. Nyob rau hauv cov ntaub ntawv inline, peb rov pib dua qhov width: auto;ntawd kom ntau yam kev tswj hwm tuaj yeem nyob ntawm tib kab. Nyob ntawm koj qhov layout, ntxiv kev cai dav yuav xav tau.

Ib txwm ntxiv daim ntawv lo

Cov neeg nyeem ntawv yuav muaj teeb meem nrog koj cov ntawv yog tias koj tsis suav nrog daim ntawv lo rau txhua qhov kev tawm tswv yim. Rau cov ntaub ntawv hauv kab no, koj tuaj yeem nkaum cov ntawv lo siv cov .sr-onlychav kawm. Muaj lwm txoj hauv kev los muab ib daim ntawv lo rau cov cuab yeej pabcuam, xws li aria-label, aria-labelledbylossis titletus cwj pwm. Yog tias tsis muaj ib qho ntawm cov no tam sim no, cov neeg siv tshuaj ntsuam tuaj yeem siv rau kev siv tus placeholdercwj pwm, yog tias tam sim no, tab sis nco ntsoov tias kev siv placeholderlos hloov lwm txoj kev sau npe tsis raug qhia.

<form class="form-inline">
  <div class="form-group">
    <label for="exampleInputName2">Name</label>
    <input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
  </div>
  <div class="form-group">
    <label for="exampleInputEmail2">Email</label>
    <input type="email" class="form-control" id="exampleInputEmail2" placeholder="[email protected]">
  </div>
  <button type="submit" class="btn btn-default">Send invitation</button>
</form>
<form class="form-inline">
  <div class="form-group">
    <label class="sr-only" for="exampleInputEmail3">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail3" placeholder="Email">
  </div>
  <div class="form-group">
    <label class="sr-only" for="exampleInputPassword3">Password</label>
    <input type="password" class="form-control" id="exampleInputPassword3" placeholder="Password">
  </div>
  <div class="checkbox">
    <label>
      <input type="checkbox"> Remember me
    </label>
  </div>
  <button type="submit" class="btn btn-default">Sign in</button>
</form>
$
.00
<form class="form-inline">
  <div class="form-group">
    <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
    <div class="input-group">
      <div class="input-group-addon">$</div>
      <input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
      <div class="input-group-addon">.00</div>
    </div>
  </div>
  <button type="submit" class="btn btn-primary">Transfer cash</button>
</form>

Kab rov tav daim ntawv

Siv Bootstrap cov chav kawm ntawv teev tseg ua ntej los kho cov ntawv sau thiab pab pawg ntawm cov ntawv tswj hauv kab rov tav los ntawm kev ntxiv .form-horizontalrau daim ntawv (uas tsis tas yuav yog ib qho <form>). Ua li ntawd hloov .form-groups coj li kab kab sib chaws, yog li tsis xav tau .row.

<form class="form-horizontal">
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
    <div class="col-sm-10">
      <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <div class="checkbox">
        <label>
          <input type="checkbox"> Remember me
        </label>
      </div>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default">Sign in</button>
    </div>
  </div>
</form>

Txhawb kev tswj

Piv txwv ntawm cov qauv kev tswj hwm kev txhawb nqa hauv ib qho piv txwv daim ntawv layout.

Cov tswv yim

Feem ntau hom kev tswj, cov ntawv nyeem-raws li kev nkag teb chaws. Xws li kev txhawb nqa rau txhua hom HTML5: text, password, datetime, datetime-local, date, , month, time, week, number, , email, url, search, tel, thiab color.

Hom ntawv tshaj tawm yuav tsum tau

Cov tswv yim yuav tsuas yog tag nrho styled yog tias lawv typetau tshaj tawm kom raug.

<input type="text" class="form-control" placeholder="Text input">

Input pab pawg

Txhawm rau ntxiv cov ntawv sib xyaw lossis cov nyees khawm ua ntej thiab / lossis tom qab cov ntawv nyeem <input>, kos tawm cov khoom siv hauv pawg .

Textarea

Daim ntawv tswj uas txhawb nqa ntau cov kab ntawv. Hloov rowstus cwj pwm raws li qhov tsim nyog.

<textarea class="form-control" rows="3"></textarea>

Checkboxes thiab xov tooj cua

Checkboxes yog xaiv ib lossis ntau txoj hauv kev hauv ib daim ntawv teev npe, thaum lub xov tooj cua yog xaiv ib qho kev xaiv los ntawm ntau.

Cov neeg xiam oob qhab checkboxes thiab xov tooj cua tau txais kev txhawb nqa, tab sis kom muab tus cursor "tsis tso cai" rau ntawm tus niam txiv hover <label>, koj yuav tsum tau ntxiv cov .disabledchav kawm rau niam txiv .radio, .radio-inline, .checkbox, lossis .checkbox-inline.

Default (stacked)


<div class="checkbox">
  <label>
    <input type="checkbox" value="">
    Option one is this and that&mdash;be sure to include why it's great
  </label>
</div>
<div class="checkbox disabled">
  <label>
    <input type="checkbox" value="" disabled>
    Option two is disabled
  </label>
</div>

<div class="radio">
  <label>
    <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
    Option one is this and that&mdash;be sure to include why it's great
  </label>
</div>
<div class="radio">
  <label>
    <input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
    Option two can be something else and selecting it will deselect option one
  </label>
</div>
<div class="radio disabled">
  <label>
    <input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
    Option three is disabled
  </label>
</div>

Inline checkboxes thiab xov tooj cua

Siv cov ntawv .checkbox-inlinelossis .radio-inlinecov chav kawm ntawm cov ntawv txheeb lossis xov tooj cua rau kev tswj hwm uas tshwm sim ntawm tib kab.


<label class="checkbox-inline">
  <input type="checkbox" id="inlineCheckbox1" value="option1"> 1
</label>
<label class="checkbox-inline">
  <input type="checkbox" id="inlineCheckbox2" value="option2"> 2
</label>
<label class="checkbox-inline">
  <input type="checkbox" id="inlineCheckbox3" value="option3"> 3
</label>

<label class="radio-inline">
  <input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1"> 1
</label>
<label class="radio-inline">
  <input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2"> 2
</label>
<label class="radio-inline">
  <input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3"> 3
</label>

Checkboxes thiab xov tooj cua tsis muaj ntawv sau npe

Yog tias koj tsis muaj cov ntawv sau nyob rau hauv <label>, cov tswv yim yog positioned raws li koj xav tau. Tam sim no tsuas yog ua haujlwm ntawm lub npov tsis-inline thiab xov tooj cua. Nco ntsoov tseem muab qee daim ntawv lo rau cov cuab yeej pabcuam (piv txwv li, siv aria-label).

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

Xaiv

Nco ntsoov tias ntau haiv neeg xaiv cov ntawv qhia zaub mov - xws li hauv Safari thiab Chrome - muaj cov ces kaum uas tsis tuaj yeem hloov kho ntawm border-radiuscov khoom.

<select class="form-control">
  <option>1</option>
  <option>2</option>
  <option>3</option>
  <option>4</option>
  <option>5</option>
</select>

Rau <select>kev tswj hwm nrog tus multiplecwj pwm, ntau yam kev xaiv tau pom los ntawm lub neej ntawd.

<select multiple class="form-control">
  <option>1</option>
  <option>2</option>
  <option>3</option>
  <option>4</option>
  <option>5</option>
</select>

Static tswj

Thaum koj yuav tsum tso cov ntawv dawb nyob ib sab ntawm daim ntawv lo rau hauv ib daim ntawv, siv cov .form-control-staticchav kawm ntawm a <p>.

<form class="form-horizontal">
  <div class="form-group">
    <label class="col-sm-2 control-label">Email</label>
    <div class="col-sm-10">
      <p class="form-control-static">[email protected]</p>
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword" class="col-sm-2 control-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">
    <label class="sr-only">Email</label>
    <p class="form-control-static">[email protected]</p>
  </div>
  <div class="form-group">
    <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-default">Confirm identity</button>
</form>

Focus xeev

Peb tshem tawm cov outlineqauv qub ntawm qee daim ntawv tswj hwm thiab siv ib qho box-shadowhauv nws qhov chaw rau :focus.

Demo :focusxeev

Cov lus piv txwv saum toj no siv cov qauv kev cai hauv peb cov ntaub ntawv los ua kom pom lub :focusxeev ntawm a .form-control.

Lub xeev tsis taus

Ntxiv tus disabledcwj pwm boolean ntawm cov tswv yim los tiv thaiv cov neeg siv kev sib cuam tshuam. Disabled inputs tshwm sib dua thiab ntxiv tus not-allowedcursor.

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

Disabled fieldsets

Ntxiv tus disabledcwj pwm rau ib qho <fieldset>kom lov tes taw tag nrho cov tswj hauv <fieldset>ib zaug.

Caveat txog txuas functionality ntawm<a>

Los ntawm lub neej ntawd, browsers yuav kho txhua hom kev tswj hwm ib txwm muaj ( <input>, <select>thiab <button>cov ntsiab lus ) hauv qhov <fieldset disabled>ua tsis taus, tiv thaiv ob qho tib si keyboard thiab nas cuam tshuam rau lawv. Txawm li cas los xij, yog tias koj daim ntawv tseem suav nrog <a ... class="btn btn-*">cov ntsiab lus, cov no tsuas yog muab cov style ntawm pointer-events: none. Raws li tau sau tseg hauv ntu hais txog cov neeg xiam oob qhab rau cov nyees khawm (thiab tshwj xeeb hauv ntu ntu rau cov khoom thauj tog rau nkoj), CSS cov cuab yeej no tseem tsis tau muaj tus qauv thiab tsis tau txais kev txhawb nqa tag nrho hauv Opera 18 thiab hauv qab no, lossis hauv Internet Explorer 11, thiab yeej. 'tsis tiv thaiv cov neeg siv keyboard los ntawm kev ua kom pom tseeb lossis qhib cov kev txuas no. Yog li kom muaj kev nyab xeeb, siv kev cai JavaScript los lov tes taw cov kev sib txuas.

Cross-browser compatibility

Thaum Bootstrap yuav siv cov qauv no hauv txhua qhov browsers, Internet Explorer 11 thiab hauv qab no tsis txhawb nqa tus disabledcwj pwm ntawm <fieldset>. Siv kev cai JavaScript los lov tes taw cov fieldset hauv cov browsers no.

<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="checkbox">
      <label>
        <input type="checkbox"> Can't check this
      </label>
    </div>
    <button type="submit" class="btn btn-primary">Submit</button>
  </fieldset>
</form>

Readonly xeev

Ntxiv tus readonlycwj pwm boolean ntawm ib qho kev tawm tswv yim los tiv thaiv kev hloov pauv ntawm cov tswv yim tus nqi. Cov ntawv nyeem nkaus xwb zoo li sib dua (ib yam li cov khoom siv tsis taus), tab sis khaws tus cursor tus qauv.

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

Pab ntawv nyeem

Thaiv qib pab ntawv nyeem rau daim ntawv tswj.

Koom nrog kev pab cov ntawv nyeem nrog cov ntawv tswj hwm

Cov ntawv nyeem yuav tsum qhia meej meej nrog rau daim ntawv tswj nws cuam tshuam nrog kev siv tus aria-describedbycwj pwm. Qhov no yuav ua kom ntseeg tau tias cov thev naus laus zis pabcuam - xws li cov neeg nyeem tshuaj ntsuam - yuav tshaj tawm cov ntawv pabcuam no thaum tus neeg siv tsom lossis nkag mus rau kev tswj hwm.

Ib qho thaiv ntawm kev pab cov ntawv uas tawg mus rau ib kab tshiab thiab tuaj yeem txuas mus dhau ib kab.
<label class="sr-only" for="inputHelpBlock">Input with help text</label>
<input type="text" id="inputHelpBlock" class="form-control" aria-describedby="helpBlock">
...
<span id="helpBlock" class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>

Validation hais

Bootstrap suav nrog cov qauv kev lees paub rau kev ua yuam kev, ceeb toom, thiab kev ua tiav ntawm cov ntawv tswj hwm. Txhawm rau siv, ntxiv .has-warning, .has-error, lossis .has-successrau cov khoom niam txiv. Ib qho .control-label, .form-control, thiab .help-blockhauv cov khoom ntawd yuav tau txais cov qauv kev lees paub.

Kev xa cov ntaub ntawv pov thawj rau cov thev naus laus zis thiab cov neeg siv tsis pom kev

Siv cov qauv kev siv tau no los qhia txog lub xeev ntawm daim ntawv tswj xyuas tsuas yog muab qhov pom, xim raws li qhia, uas yuav tsis raug xa mus rau cov neeg siv cov thev naus laus zis - xws li kev tshuaj ntsuam nyeem - lossis rau cov neeg siv tsis pom kev.

Xyuas kom meej tias muaj lwm qhov qhia txog lub xeev. Piv txwv li, koj tuaj yeem suav nrog cov lus qhia txog lub xeev hauv daim ntawv tswj cov <label>ntawv nws tus kheej (raws li qhov xwm txheej hauv qhov piv txwv hauv qab no), suav nrog Glyphicon (nrog cov ntawv tsim nyog siv cov .sr-onlychav kawm - saib Glyphicon piv txwv ), lossis los ntawm kev muab ib qho ntxiv kev pab ntawv thaiv. Tshwj xeeb rau cov thev naus laus zis, kev tswj tsis tau daim ntawv tseem tuaj yeem raug muab rau tus aria-invalid="true"cwj pwm.

Ib qho thaiv ntawm kev pab cov ntawv uas tawg mus rau ib kab tshiab thiab tuaj yeem txuas mus dhau ib kab.
<div class="form-group has-success">
  <label class="control-label" for="inputSuccess1">Input with success</label>
  <input type="text" class="form-control" id="inputSuccess1" aria-describedby="helpBlock2">
  <span id="helpBlock2" class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>
</div>
<div class="form-group has-warning">
  <label class="control-label" for="inputWarning1">Input with warning</label>
  <input type="text" class="form-control" id="inputWarning1">
</div>
<div class="form-group has-error">
  <label class="control-label" for="inputError1">Input with error</label>
  <input type="text" class="form-control" id="inputError1">
</div>
<div class="has-success">
  <div class="checkbox">
    <label>
      <input type="checkbox" id="checkboxSuccess" value="option1">
      Checkbox with success
    </label>
  </div>
</div>
<div class="has-warning">
  <div class="checkbox">
    <label>
      <input type="checkbox" id="checkboxWarning" value="option1">
      Checkbox with warning
    </label>
  </div>
</div>
<div class="has-error">
  <div class="checkbox">
    <label>
      <input type="checkbox" id="checkboxError" value="option1">
      Checkbox with error
    </label>
  </div>
</div>

Nrog xaiv icons

Koj tseem tuaj yeem ntxiv cov tswv yim xaiv icons nrog qhov sib ntxiv ntawm .has-feedbackthiab lub cim zoo.

Cov lus teb cov lus pom tsuas yog ua haujlwm nrog cov ntawv nyeem <input class="form-control">.

Icons, daim ntawv lo, thiab pab pawg nkag

Kev tuav tuav ntawm cov lus tawm tswv yim yuav tsum muaj rau cov tswv yim yam tsis muaj daim ntawv lo thiab rau cov tswv yim pab pawg nrog ib qho ntxiv ntawm sab xis. Koj raug txhawb kom muab cov ntawv sau rau txhua qhov kev nkag mus rau qhov laj thawj nkag tau. Yog tias koj xav tiv thaiv cov ntawv los ntawm kev nthuav tawm, zais lawv nrog .sr-onlychav kawm. Yog tias koj yuav tsum ua yam tsis muaj daim ntawv lo, kho tus topnqi ntawm lub tswv yim icon. Rau cov tswv yim pab pawg, kho tus rightnqi rau qhov tsim nyog pixel tus nqi nyob ntawm qhov dav ntawm koj qhov addon.

Tshaj tawm lub cim lub ntsiab lus rau kev pab technologies

Txhawm rau kom ntseeg tau tias cov thev naus laus zis pabcuam - xws li kev tshuaj ntsuam nyeem ntawv - raug qhia lub ntsiab lus ntawm lub cim, cov ntawv zais ntxiv yuav tsum tau suav nrog hauv .sr-onlychav kawm thiab qhia meej nrog rau daim ntawv tswj nws cuam tshuam txog kev siv aria-describedby. Xwb, xyuas kom meej tias lub ntsiab lus (piv txwv li, qhov tseeb tias muaj lus ceeb toom rau ib qho kev sau ntawv nkag teb) raug xa mus rau lwm daim ntawv, xws li hloov cov ntawv ntawm qhov tseeb <label>cuam tshuam nrog daim ntawv tswj.

Txawm hais tias cov piv txwv hauv qab no twb tau hais txog qhov kev lees paub ntawm lawv cov ntawv tswj hwm hauv cov <label>ntawv nyeem nws tus kheej, cov txheej txheem saum toj no (siv .sr-onlycov ntawv nyeem thiab aria-describedby) tau suav nrog rau cov ntsiab lus piav qhia.

(kev vam meej)
(ceeb toom)
(yuam kev)
@
(kev vam meej)
<div class="form-group has-success has-feedback">
  <label class="control-label" for="inputSuccess2">Input with success</label>
  <input type="text" class="form-control" id="inputSuccess2" aria-describedby="inputSuccess2Status">
  <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
  <span id="inputSuccess2Status" class="sr-only">(success)</span>
</div>
<div class="form-group has-warning has-feedback">
  <label class="control-label" for="inputWarning2">Input with warning</label>
  <input type="text" class="form-control" id="inputWarning2" aria-describedby="inputWarning2Status">
  <span class="glyphicon glyphicon-warning-sign form-control-feedback" aria-hidden="true"></span>
  <span id="inputWarning2Status" class="sr-only">(warning)</span>
</div>
<div class="form-group has-error has-feedback">
  <label class="control-label" for="inputError2">Input with error</label>
  <input type="text" class="form-control" id="inputError2" aria-describedby="inputError2Status">
  <span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>
  <span id="inputError2Status" class="sr-only">(error)</span>
</div>
<div class="form-group has-success has-feedback">
  <label class="control-label" for="inputGroupSuccess1">Input group with success</label>
  <div class="input-group">
    <span class="input-group-addon">@</span>
    <input type="text" class="form-control" id="inputGroupSuccess1" aria-describedby="inputGroupSuccess1Status">
  </div>
  <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
  <span id="inputGroupSuccess1Status" class="sr-only">(success)</span>
</div>

Yeem icons nyob rau hauv kab rov tav thiab inline daim ntawv

(kev vam meej)
@
(kev vam meej)
<form class="form-horizontal">
  <div class="form-group has-success has-feedback">
    <label class="control-label col-sm-3" for="inputSuccess3">Input with success</label>
    <div class="col-sm-9">
      <input type="text" class="form-control" id="inputSuccess3" aria-describedby="inputSuccess3Status">
      <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
      <span id="inputSuccess3Status" class="sr-only">(success)</span>
    </div>
  </div>
  <div class="form-group has-success has-feedback">
    <label class="control-label col-sm-3" for="inputGroupSuccess2">Input group with success</label>
    <div class="col-sm-9">
      <div class="input-group">
        <span class="input-group-addon">@</span>
        <input type="text" class="form-control" id="inputGroupSuccess2" aria-describedby="inputGroupSuccess2Status">
      </div>
      <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
      <span id="inputGroupSuccess2Status" class="sr-only">(success)</span>
    </div>
  </div>
</form>
(kev vam meej)

@
(kev vam meej)
<form class="form-inline">
  <div class="form-group has-success has-feedback">
    <label class="control-label" for="inputSuccess4">Input with success</label>
    <input type="text" class="form-control" id="inputSuccess4" aria-describedby="inputSuccess4Status">
    <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
    <span id="inputSuccess4Status" class="sr-only">(success)</span>
  </div>
</form>
<form class="form-inline">
  <div class="form-group has-success has-feedback">
    <label class="control-label" for="inputGroupSuccess3">Input group with success</label>
    <div class="input-group">
      <span class="input-group-addon">@</span>
      <input type="text" class="form-control" id="inputGroupSuccess3" aria-describedby="inputGroupSuccess3Status">
    </div>
    <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
    <span id="inputGroupSuccess3Status" class="sr-only">(success)</span>
  </div>
</form>

Yeem icons nrog cov .sr-onlyntawv zais

Yog tias koj siv cov .sr-onlychav kawm los nkaum daim ntawv tswj hwm <label>(tsis yog siv lwm cov ntawv sau npe, xws li tus aria-labelcwj pwm), Bootstrap yuav hloov kho txoj haujlwm ntawm lub cim thaum nws tau ntxiv.

(kev vam meej)
@
(kev vam meej)
<div class="form-group has-success has-feedback">
  <label class="control-label sr-only" for="inputSuccess5">Hidden label</label>
  <input type="text" class="form-control" id="inputSuccess5" aria-describedby="inputSuccess5Status">
  <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
  <span id="inputSuccess5Status" class="sr-only">(success)</span>
</div>
<div class="form-group has-success has-feedback">
  <label class="control-label sr-only" for="inputGroupSuccess4">Input group with success</label>
  <div class="input-group">
    <span class="input-group-addon">@</span>
    <input type="text" class="form-control" id="inputGroupSuccess4" aria-describedby="inputGroupSuccess4Status">
  </div>
  <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
  <span id="inputGroupSuccess4Status" class="sr-only">(success)</span>
</div>

Tswj qhov loj me

Teem qhov siab siv cov chav kawm xws li .input-lg, thiab teeb tsa qhov dav siv kab ke kab ntawv zoo li .col-lg-*.

Qhov siab qhov loj me

Tsim daim ntawv siab dua los yog luv dua tswj uas phim cov pob loj.

<input class="form-control input-lg" type="text" placeholder=".input-lg">
<input class="form-control" type="text" placeholder="Default input">
<input class="form-control input-sm" type="text" placeholder=".input-sm">

<select class="form-control input-lg">...</select>
<select class="form-control">...</select>
<select class="form-control input-sm">...</select>

Kab rov tav daim ntawv pab pawg qhov ntau thiab tsawg

Ceev cov ntawv loj thiab daim ntawv tswj tsis pub dhau .form-horizontallos ntawm kev ntxiv .form-group-lglossis .form-group-sm.

<form class="form-horizontal">
  <div class="form-group form-group-lg">
    <label class="col-sm-2 control-label" for="formGroupInputLarge">Large label</label>
    <div class="col-sm-10">
      <input class="form-control" type="text" id="formGroupInputLarge" placeholder="Large input">
    </div>
  </div>
  <div class="form-group form-group-sm">
    <label class="col-sm-2 control-label" for="formGroupInputSmall">Small label</label>
    <div class="col-sm-10">
      <input class="form-control" type="text" id="formGroupInputSmall" placeholder="Small input">
    </div>
  </div>
</form>

Kem qhov loj me

Qhwv cov khoom nkag rau hauv kab kab kab, lossis ib qho kev cai niam txiv, kom yooj yim tswj qhov dav xav tau.

<div class="row">
  <div class="col-xs-2">
    <input type="text" class="form-control" placeholder=".col-xs-2">
  </div>
  <div class="col-xs-3">
    <input type="text" class="form-control" placeholder=".col-xs-3">
  </div>
  <div class="col-xs-4">
    <input type="text" class="form-control" placeholder=".col-xs-4">
  </div>
</div>

Khawm

Khawm tag

Siv cov chav kawm khawm ntawm ib qho <a>, <button>, lossis <input>cov khoom.

Txuas
<a class="btn btn-default" href="#" role="button">Link</a>
<button class="btn btn-default" type="submit">Button</button>
<input class="btn btn-default" type="button" value="Input">
<input class="btn btn-default" type="submit" value="Submit">

Kev siv cov ntsiab lus tshwj xeeb

Thaum cov chav kawm khawm tuaj yeem siv rau <a>thiab <button>cov ntsiab lus, tsuas yog <button>cov ntsiab lus tau txais kev txhawb nqa hauv peb cov khoom siv nav thiab navbar.

Links ua raws li cov nyees khawm

Yog tias cov <a>ntsiab lus raug siv los ua cov nyees khawm - ua rau hauv nplooj ntawv ua haujlwm, es tsis yog mus rau lwm daim ntawv lossis ntu hauv nplooj ntawv tam sim no - lawv kuj yuav tsum tau muab qhov tsim nyog role="button".

Hla-browser rendering

Raws li qhov kev coj ua zoo tshaj plaws, peb pom zoo kom siv lub <button>ntsiab lus thaum twg los tau los xyuas kom meej qhov sib piv ntawm qhov browser rendering.

Ntawm lwm yam, muaj kab laum hauv Firefox <30 uas tiv thaiv peb los ntawm kev teeb tsa cov nyees khawm line-heightntawm <input>-raws li, ua rau lawv tsis haum rau qhov siab ntawm lwm cov nyees khawm ntawm Firefox.

Kev xaiv

Siv ib qho ntawm cov chav kawm khawm muaj kom sai sai tsim ib lub pob styled.

<!-- Standard button -->
<button type="button" class="btn btn-default">Default</button>

<!-- Provides extra visual weight and identifies the primary action in a set of buttons -->
<button type="button" class="btn btn-primary">Primary</button>

<!-- Indicates a successful or positive action -->
<button type="button" class="btn btn-success">Success</button>

<!-- Contextual button for informational alert messages -->
<button type="button" class="btn btn-info">Info</button>

<!-- Indicates caution should be taken with this action -->
<button type="button" class="btn btn-warning">Warning</button>

<!-- Indicates a dangerous or potentially negative action -->
<button type="button" class="btn btn-danger">Danger</button>

<!-- Deemphasize a button by making it look like a link while maintaining button behavior -->
<button type="button" class="btn btn-link">Link</button>

Qhia lub ntsiab lus rau kev pab technologies

Siv cov xim los ntxiv cov ntsiab lus rau lub pob tsuas yog muab qhov pom kev pom, uas yuav tsis raug xa mus rau cov neeg siv khoom siv thev naus laus zis - xws li cov ntawv nyeem. Xyuas kom meej tias cov ntaub ntawv qhia los ntawm cov xim yog pom tseeb los ntawm cov ntsiab lus nws tus kheej (cov ntawv pom ntawm lub pob), lossis suav nrog lwm txoj kev, xws li cov ntawv ntxiv zais nrog cov .sr-onlychav kawm.

Qhov ntau thiab tsawg

Xav tau cov nyees khawm loj lossis me dua? Ntxiv .btn-lg, .btn-sm, lossis .btn-xsrau qhov ntau thiab tsawg.

<p>
  <button type="button" class="btn btn-primary btn-lg">Large button</button>
  <button type="button" class="btn btn-default btn-lg">Large button</button>
</p>
<p>
  <button type="button" class="btn btn-primary">Default button</button>
  <button type="button" class="btn btn-default">Default button</button>
</p>
<p>
  <button type="button" class="btn btn-primary btn-sm">Small button</button>
  <button type="button" class="btn btn-default btn-sm">Small button</button>
</p>
<p>
  <button type="button" class="btn btn-primary btn-xs">Extra small button</button>
  <button type="button" class="btn btn-default btn-xs">Extra small button</button>
</p>

Tsim thaiv qib nyees khawm-cov uas nthuav dav dav ntawm niam txiv- los ntawm kev ntxiv .btn-block.

<button type="button" class="btn btn-primary btn-lg btn-block">Block level button</button>
<button type="button" class="btn btn-default btn-lg btn-block">Block level button</button>

Active lub xeev

Cov nyees khawm yuav tshwm sim (nrog rau tom qab tsaus nti, ciam teb tsaus nti, thiab teeb duab ntxoov ntxoo) thaum ua haujlwm. Rau <button>cov ntsiab lus, qhov no yog ua los ntawm :active. Rau <a>cov ntsiab lus, nws tau ua tiav nrog .active. Txawm li cas los xij, koj tuaj yeem siv .activerau ntawm <button>s (thiab suav nrog tus aria-pressed="true"cwj pwm) yog tias koj xav tau rov ua dua lub xeev nquag ua haujlwm.

Khawm element

Tsis tas yuav ntxiv :activeraws li nws yog pseudo-chav kawm, tab sis yog tias koj xav tau yuam kom zoo li qub, mus tom ntej thiab ntxiv .active.

<button type="button" class="btn btn-primary btn-lg active">Primary button</button>
<button type="button" class="btn btn-default btn-lg active">Button</button>

Anchor element

Ntxiv cov .activechav kawm rau <a>cov nyees khawm.

Thawj qhov txuas Txuas

<a href="#" class="btn btn-primary btn-lg active" role="button">Primary link</a>
<a href="#" class="btn btn-default btn-lg active" role="button">Link</a>

Lub xeev tsis taus

Ua cov nyees khawm zoo li unclickable los ntawm fading lawv rov qab nrog opacity.

Khawm element

Ntxiv tus disabledcwj pwm rau <button>cov nyees khawm.

<button type="button" class="btn btn-lg btn-primary" disabled="disabled">Primary button</button>
<button type="button" class="btn btn-default btn-lg" disabled="disabled">Button</button>

Cross-browser compatibility

Yog tias koj ntxiv tus disabledcwj pwm rau ib qho <button>, Internet Explorer 9 thiab hauv qab no yuav ua cov ntawv grey nrog cov ntawv tsis zoo-duab ntxoov ntxoo uas peb kho tsis tau.

Anchor element

Ntxiv cov .disabledchav kawm rau <a>cov nyees khawm.

Thawj qhov txuas Txuas

<a href="#" class="btn btn-primary btn-lg disabled" role="button">Primary link</a>
<a href="#" class="btn btn-default btn-lg disabled" role="button">Link</a>

Peb siv .disabledraws li chav kawm siv hluav taws xob ntawm no, zoo ib yam li cov .activechav kawm sib xws, yog li tsis tas yuav tsum tau ua ntej.

Link functionality caveat

Cov chav kawm no siv pointer-events: nonelos sim lov tes taw kev ua haujlwm txuas ntawm <a>s, tab sis cov cuab yeej CSS tseem tsis tau ua qauv thiab tsis tau txais kev txhawb siab hauv Opera 18 thiab hauv qab no, lossis hauv Internet Explorer 11. Tsis tas li ntawd, txawm nyob hauv browsers uas txhawb nqa pointer-events: none, keyboard. navigation tseem tsis cuam tshuam, txhais tau hais tias cov neeg siv cov keyboard pom thiab cov neeg siv cov cuab yeej pabcuam tseem tuaj yeem qhib cov kev txuas no. Yog li kom muaj kev nyab xeeb, siv kev cai JavaScript los lov tes taw cov kev sib txuas.

Duab

Teb cov duab

Cov duab hauv Bootstrap 3 tuaj yeem ua tau raws li tus phooj ywg ntawm qhov sib ntxiv ntawm .img-responsivechav kawm. Qhov no siv max-width: 100%;, height: auto;thiab display: block;rau cov duab kom nws scales nicely rau niam txiv lub caij.

Txhawm rau nruab nrab cov duab uas siv cov .img-responsivechav kawm, siv .center-blocktsis yog .text-center. Saib cov chav kawm pab kom paub meej ntxiv txog .center-blockkev siv.

SVG cov duab thiab IE 8-10

Hauv Internet Explorer 8-10, SVG cov duab nrog .img-responsiveqhov loj me me. Txhawm rau kho qhov no, ntxiv width: 100% \9;qhov tsim nyog. Bootstrap tsis siv qhov no cia li ua rau muaj teeb meem rau lwm hom duab.

<img src="..." class="img-responsive" alt="Responsive image">

Cov duab duab

Ntxiv cov chav kawm rau ib <img>lub caij kom yooj yim style dluab nyob rau hauv txhua qhov project.

Cross-browser compatibility

Nco ntsoov tias Internet Explorer 8 tsis muaj kev txhawb nqa rau cov ces kaum sib npaug.

140 x 140 140 x 140 140 x 140
<img src="..." alt="..." class="img-rounded">
<img src="..." alt="..." class="img-circle">
<img src="..." alt="..." class="img-thumbnail">

Cov chav kawm pab

Cov ntsiab lus xim

Qhia lub ntsiab lus los ntawm cov xim nrog ib txhais tes ntawm cov chav kawm siv hluav taws xob. Cov no kuj tseem siv tau rau cov kev sib txuas thiab yuav tsaus ntuj rau ntawm hover ib yam li peb cov qauv txuas txuas.

Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.

Nullam id dolor id nibh ultricies vehicula ut id elit.

Duis mollis, tsis yog commodo luctus, nisi erat porttitor ligula.

Maecenas sed diam eget risus varius blandit zaum amet tsis magna.

Etiam porta sem malesuada magna mollis euismod.

Donec ullamcorper nulla non metus auctor fringilla.

<p class="text-muted">...</p>
<p class="text-primary">...</p>
<p class="text-success">...</p>
<p class="text-info">...</p>
<p class="text-warning">...</p>
<p class="text-danger">...</p>

Hais txog qhov tshwj xeeb

Qee zaum cov chav kawm tseem ceeb tsis tuaj yeem siv vim qhov tshwj xeeb ntawm lwm tus neeg xaiv. Feem ntau, ib qho kev ua haujlwm txaus yog los qhwv koj cov ntawv hauv ib chav <span>nrog chav kawm.

Qhia lub ntsiab lus rau kev pab technologies

Siv cov xim los ntxiv cov ntsiab lus tsuas yog muab qhov pom kev pom, uas yuav tsis raug xa mus rau cov neeg siv cov thev naus laus zis pab - xws li cov ntawv nyeem. Xyuas kom meej tias cov ntaub ntawv qhia los ntawm cov xim yog pom tseeb los ntawm cov ntsiab lus nws tus kheej (cov ntsiab lus xim tsuas yog siv los txhawb lub ntsiab lus uas twb muaj nyob rau hauv cov ntawv nyeem / cim), lossis suav nrog lwm txoj kev, xws li cov ntawv ntxiv zais nrog cov .sr-onlychav kawm . .

Cov ntsiab lus keeb kwm yav dhau

Zoo ib yam li cov chav kawm ntawv xim xim, yooj yim teeb lub keeb kwm yav dhau ntawm ib lub caij rau txhua chav kawm ntawv. Anchor Cheebtsam yuav tsaus rau hover, ib yam li cov ntawv nyeem.

Nullam id dolor id nibh ultricies vehicula ut id elit.

Duis mollis, tsis yog commodo luctus, nisi erat porttitor ligula.

Maecenas sed diam eget risus varius blandit zaum amet tsis magna.

Etiam porta sem malesuada magna mollis euismod.

Donec ullamcorper nulla non metus auctor fringilla.

<p class="bg-primary">...</p>
<p class="bg-success">...</p>
<p class="bg-info">...</p>
<p class="bg-warning">...</p>
<p class="bg-danger">...</p>

Hais txog qhov tshwj xeeb

Qee zaum cov chav kawm keeb kwm yav dhau los tsis tuaj yeem siv vim qhov tshwj xeeb ntawm lwm tus neeg xaiv. Qee zaum, kev ua haujlwm txaus yog los qhwv koj lub ntsiab lus hauv ib chav <div>nrog chav kawm.

Qhia lub ntsiab lus rau kev pab technologies

Raws li nrog cov xim contextual , xyuas kom meej tias txhua lub ntsiab lus uas tau hais los ntawm cov xim kuj tau nthuav tawm hauv ib hom ntawv uas tsis yog kev nthuav qhia.

Kaw lub cim

Siv lub cim ze ze rau kev tso tawm cov ntsiab lus xws li modals thiab ceeb toom.

<button type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>

Carets

Siv carts los qhia txog kev ua haujlwm poob qis thiab kev taw qhia. Nco ntsoov tias lub neej ntawd caret yuav thim rov qab rau hauv dropup menus .

<span class="caret"></span>

Ceev ceev ntab

Float ib lub caij mus rau sab laug lossis sab xis nrog chav kawm. !importantsuav nrog kom tsis txhob muaj teeb meem tshwj xeeb. Cov chav kawm kuj tseem siv tau ua cov mixins.

<div class="pull-left">...</div>
<div class="pull-right">...</div>
// Classes
.pull-left {
  float: left !important;
}
.pull-right {
  float: right !important;
}

// Usage as mixins
.element {
  .pull-left();
}
.another-element {
  .pull-right();
}

Tsis siv rau hauv navbars

Txhawm rau kho cov khoom hauv navbars nrog cov chav kawm siv hluav taws xob, siv .navbar-leftlossis .navbar-righthloov. Saib cov ntaub ntawv navbar kom paub meej.

Center cov ntsiab lus blocks

Teem lub ntsiab rau display: blockthiab nruab nrab ntawm margin. Muaj raws li kev sib xyaw thiab chav kawm.

<div class="center-block">...</div>
// Class
.center-block {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

// Usage as a mixin
.element {
  .center-block();
}

Clearfix

Yooj yim tshem floats los ntawm kev ntxiv .clearfix rau cov niam txiv keeb . Siv micro clearfix li nrov los ntawm Nicolas Gallagher. Kuj tseem siv tau los ua ib qho mixin.

<!-- Usage as a class -->
<div class="clearfix">...</div>
// Mixin itself
.clearfix() {
  &:before,
  &:after {
    content: " ";
    display: table;
  }
  &:after {
    clear: both;
  }
}

// Usage as a mixin
.element {
  .clearfix();
}

Qhia thiab zais cov ntsiab lus

quab yuam kom pom lossis zais ( nrog rau cov neeg nyeem ntawv ) nrog rau kev siv .showthiab .hiddencov chav kawm. Cov chav kawm no siv !importantkom tsis txhob muaj kev tsis sib haum xeeb tshwj xeeb, ib yam li qhov nrawm nrawm . Lawv tsuas yog muaj rau thaiv qib toggling. Lawv tuaj yeem siv los ua cov mixins.

.hidemuaj, tab sis nws tsis tas yuav cuam tshuam rau cov neeg nyeem ntawv tshuaj ntsuam thiab yog deprecated li ntawm v3.0.1. Siv .hiddenlossis .sr-onlyhloov.

Tsis tas li ntawd, .invisibletuaj yeem siv los hloov pauv tsuas yog qhov pom ntawm lub ntsiab lus, lub ntsiab lus nws displaytsis hloov kho thiab lub ntsiab tseem tuaj yeem cuam tshuam rau qhov ntws ntawm cov ntaub ntawv.

<div class="show">...</div>
<div class="hidden">...</div>
// Classes
.show {
  display: block !important;
}
.hidden {
  display: none !important;
}
.invisible {
  visibility: hidden;
}

// Usage as mixins
.element {
  .show();
}
.another-element {
  .hidden();
}

Screen nyeem ntawv thiab cov ntsiab lus navigation keyboard

Nkaum ib lub ntsiab lus rau txhua yam khoom siv tshwj tsis yog cov ntawv nyeem nrog .sr-only. Ua ke .sr-onlynrog .sr-only-focusablelos qhia lub caij dua thaum nws tau tsom (xws li los ntawm tus neeg siv keyboard nkaus xwb). Yuav tsum tau ua raws li kev coj ua zoo tshaj plaws . Kuj tseem siv tau ua cov mixins.

<a class="sr-only sr-only-focusable" href="#content">Skip to main content</a>
// Usage as a mixin
.skip-navigation {
  .sr-only();
  .sr-only-focusable();
}

Hloov duab

Siv cov .text-hidechav kawm lossis mixin los pab hloov lub ntsiab lus cov ntsiab lus nrog cov duab tom qab.

<h1 class="text-hide">Custom heading</h1>
// Usage as a mixin
.heading {
  .text-hide();
}

Responsive utilities

Txhawm rau txhim kho lub xov tooj sai dua, siv cov chav kawm siv hluav taws xob no los qhia thiab zais cov ntsiab lus los ntawm cov khoom siv los ntawm kev nug xov xwm. Kuj tseem muaj cov chav kawm siv hluav taws xob rau toggling cov ntsiab lus thaum luam tawm.

Sim siv cov no nyob rau hauv ib qho txwv thiab tsis txhob tsim cov versions sib txawv ntawm tib lub xaib. Hloov chaw, siv lawv los ntxiv rau txhua lub cuab yeej kev nthuav qhia.

Muaj cov chav kawm

Siv ib qho los yog sib xyaw ua ke ntawm cov chav kawm muaj rau toggling cov ntsiab lus hla cov chaw saib xyuas qhov chaw.

Cov khoom siv me me ntxivXov tooj (<768px) Cov khoom siv me meCov ntsiav tshuaj (≥768px) Cov khoom siv nruab nrabDesktops (≥992px) Cov khoom siv lojDesktops (≥1200px)
.visible-xs-* Pom tau
.visible-sm-* Pom tau
.visible-md-* Pom tau
.visible-lg-* Pom tau
.hidden-xs Pom tau Pom tau Pom tau
.hidden-sm Pom tau Pom tau Pom tau
.hidden-md Pom tau Pom tau Pom tau
.hidden-lg Pom tau Pom tau Pom tau

Raws li ntawm v3.2.0, cov .visible-*-*chav kawm rau txhua qhov kev tawg tuaj nyob hauv peb qhov kev hloov pauv, ib qho rau txhua tus nqi ntawm CSS displaytau teev tseg hauv qab no.

Pab pawg ntawm cov chav kawm CSSdisplay
.visible-*-block display: block;
.visible-*-inline display: inline;
.visible-*-inline-block display: inline-block;

Yog li, xspiv txwv li, rau cov ntxaij vab tshaus me me, cov .visible-*-*chav kawm muaj xws li: .visible-xs-block, .visible-xs-inline, thiab .visible-xs-inline-block.

Cov chav kawm .visible-xs, .visible-sm, .visible-md, thiab .visible-lgtseem muaj nyob, tab sis yog deprecated raws li v3.2.0 . Lawv yog kwv yees li sib npaug rau .visible-*-block, tshwj tsis yog muaj cov xwm txheej tshwj xeeb ntxiv rau toggling <table>- ntsig txog cov ntsiab lus.

Sau cov chav kawm

Zoo ib yam li cov chav kawm teb, siv cov no rau toggling cov ntsiab lus rau luam tawm.

Cov chav kawm Browser Luam tawm
.visible-print-block
.visible-print-inline
.visible-print-inline-block
Pom tau
.hidden-print Pom tau

Cov chav kawm .visible-printkuj muaj tab sis yog deprecated raws li v3.2.0. Nws yog kwv yees li sib npaug rau .visible-print-block, tshwj tsis yog muaj cov xwm txheej tshwj xeeb ntxiv rau <table>cov ntsiab lus ntsig txog.

Kuaj cov ntaub ntawv

Hloov kho koj tus browser lossis thauj khoom ntawm cov khoom siv sib txawv los ntsuas cov chav kawm siv hluav taws xob.

Pom tau ntawm ...

Green checkmarks qhia tias lub caij pom hauv koj qhov chaw saib tam sim no.

✔ Pom tau ntawm x-me me
✔ Pom tau ntawm me me
Nruab nrab ✔ Pom tau ntawm nruab nrab
✔ Pom tau ntawm qhov loj
✔ Pom tau ntawm x-me me thiab me
✔ Pom tau ntawm nruab nrab thiab loj
✔ Pom tau ntawm x-me me thiab nruab nrab
✔ Pom tau ntawm me thiab loj
✔ Pom tau ntawm x-me me thiab loj
✔ Pom tau ntawm me thiab nruab nrab

Hidden rau...

Ntawm no, ntsuab checkmarks kuj qhia tias lub caij yog muab zais rau hauv koj qhov chaw saib tam sim no.

✔ zais ntawm x-me me
✔ Muab zais rau me me
Nruab nrab ✔ Muab zais rau nruab nrab
✔ zais ntawm qhov loj
✔ Muab zais rau x-me me thiab me
✔ Muab zais rau nruab nrab thiab loj
✔ Muab zais rau x-me me thiab nruab nrab
✔ Muab zais rau me me thiab loj
✔ Muab zais rau x-me me thiab loj
✔ Muab zais rau me me thiab nruab nrab

Siv tsawg

Bootstrap's CSS yog tsim los ntawm Less, preprocessor nrog kev ua haujlwm ntxiv xws li kev sib txawv, mixins, thiab ua haujlwm rau kev sau CSS. Cov uas tab tom nrhiav siv cov ntaub ntawv tsawg dua es tsis txhob ntawm peb cov ntaub ntawv CSS tau muab tso ua ke tuaj yeem siv ntau qhov sib txawv thiab cov khoom sib xyaw uas peb siv thoob plaws hauv lub moj khaum.

Grid variables thiab mixins yog them nyob rau hauv tshooj Grid system .

Muab tso ua ke Bootstrap

Bootstrap tuaj yeem siv tsawg kawg yog ob txoj hauv kev: nrog CSS suav nrog lossis nrog cov ntaub ntawv tsawg dua. Txhawm rau sau cov ntaub ntawv tsawg dua, sab laj rau ntu Pib pib yuav ua li cas teeb tsa koj qhov chaw tsim kho kom khiav cov lus txib tsim nyog.

Cov cuab yeej muab tso ua ke thib peb tuaj yeem ua haujlwm nrog Bootstrap, tab sis lawv tsis tau txais kev txhawb nqa los ntawm peb pab pawg tseem ceeb.

Hloov pauv

Cov kev sib txawv yog siv thoob plaws hauv qhov project tag nrho raws li ib txoj hauv kev hauv nruab nrab thiab sib faib cov txiaj ntsig uas siv ntau yam xws li xim, qhov sib txawv, lossis cov font stacks. Txhawm rau ua kom tiav, thov mus saib Customizer .

Xim

Yooj yim siv ob lub tswv yim xim: greyscale thiab semantic. Greyscale xim muab kev nkag tau sai rau cov xim dub feem ntau siv thaum lub sij hawm semantic suav nrog ntau yam xim muab rau cov ntsiab lus tseem ceeb.

@gray-darker:  lighten(#000, 13.5%); // #222
@gray-dark:    lighten(#000, 20%);   // #333
@gray:         lighten(#000, 33.5%); // #555
@gray-light:   lighten(#000, 46.7%); // #777
@gray-lighter: lighten(#000, 93.5%); // #eee
@brand-primary: darken(#428bca, 6.5%); // #337ab7
@brand-success: #5cb85c;
@brand-info:    #5bc0de;
@brand-warning: #f0ad4e;
@brand-danger:  #d9534f;

Siv ib qho ntawm cov xim hloov pauv raws li lawv yog lossis rov muab lawv rau ntau qhov sib txawv rau koj qhov project.

// Use as-is
.masthead {
  background-color: @brand-primary;
}

// Reassigned variables in Less
@alert-message-background: @brand-info;
.alert {
  background-color: @alert-message-background;
}

Scaffolding

Ib txhais tes ntawm kev hloov pauv sai sai rau kev hloov kho cov ntsiab lus tseem ceeb ntawm koj lub xaib lub cev pob txha.

// Scaffolding
@body-bg:    #fff;
@text-color: @black-50;

Yooj yim style koj cov kev sib txuas nrog cov xim zoo nrog tib tus nqi.

// Variables
@link-color:       @brand-primary;
@link-hover-color: darken(@link-color, 15%);

// Usage
a {
  color: @link-color;
  text-decoration: none;

  &:hover {
    color: @link-hover-color;
    text-decoration: underline;
  }
}

Nco ntsoov tias qhov kev @link-hover-colorsiv ib qho kev ua haujlwm, lwm lub cuab yeej txaus los ntawm Less, kom automagically tsim cov xim hover txoj cai. Koj tuaj yeem siv darken, lighten, saturate, thiab desaturate.

Typography

Yooj yim teeb tsa koj hom ntawv, ntawv loj, ua, thiab ntau ntxiv nrog ob peb qhov hloov pauv sai. Bootstrap ua rau siv cov no thiab muab cov ntawv sau yooj yim sib xyaw.

@font-family-sans-serif:  "Helvetica Neue", Helvetica, Arial, sans-serif;
@font-family-serif:       Georgia, "Times New Roman", Times, serif;
@font-family-monospace:   Menlo, Monaco, Consolas, "Courier New", monospace;
@font-family-base:        @font-family-sans-serif;

@font-size-base:          14px;
@font-size-large:         ceil((@font-size-base * 1.25)); // ~18px
@font-size-small:         ceil((@font-size-base * 0.85)); // ~12px

@font-size-h1:            floor((@font-size-base * 2.6)); // ~36px
@font-size-h2:            floor((@font-size-base * 2.15)); // ~30px
@font-size-h3:            ceil((@font-size-base * 1.7)); // ~24px
@font-size-h4:            ceil((@font-size-base * 1.25)); // ~18px
@font-size-h5:            @font-size-base;
@font-size-h6:            ceil((@font-size-base * 0.85)); // ~12px

@line-height-base:        1.428571429; // 20/14
@line-height-computed:    floor((@font-size-base * @line-height-base)); // ~20px

@headings-font-family:    inherit;
@headings-font-weight:    500;
@headings-line-height:    1.1;
@headings-color:          inherit;

Icons

Ob qhov hloov pauv ceev rau customizing qhov chaw thiab filename ntawm koj lub cim.

@icon-font-path:          "../fonts/";
@icon-font-name:          "glyphicons-halflings-regular";

Cheebtsam

Cov Cheebtsam thoob plaws hauv Bootstrap ua rau siv qee qhov kev hloov pauv tsis zoo rau kev teeb tsa cov txiaj ntsig zoo. Ntawm no yog cov feem ntau siv.

@padding-base-vertical:          6px;
@padding-base-horizontal:        12px;

@padding-large-vertical:         10px;
@padding-large-horizontal:       16px;

@padding-small-vertical:         5px;
@padding-small-horizontal:       10px;

@padding-xs-vertical:            1px;
@padding-xs-horizontal:          5px;

@line-height-large:              1.33;
@line-height-small:              1.5;

@border-radius-base:             4px;
@border-radius-large:            6px;
@border-radius-small:            3px;

@component-active-color:         #fff;
@component-active-bg:            @brand-primary;

@caret-width-base:               4px;
@caret-width-large:              5px;

Cov neeg muag khoom mixins

Cov neeg muag khoom mixins yog cov mixins los pab txhawb ntau lub browsers los ntawm kev suav nrog txhua tus neeg muag khoom npe ua ntej hauv koj li CSS.

Box-sizing

Pib dua koj cov khoom 'lub thawv qauv nrog ib qho mixin. Rau cov ntsiab lus, saib cov kab lus no pab tau los ntawm Mozilla .

Cov mixin yog deprecated li ntawm v3.2.0, nrog rau kev taw qhia ntawm Autoprefixer. Txhawm rau khaws rov qab-kev sib raug zoo, Bootstrap yuav txuas ntxiv siv cov mixin sab hauv kom txog thaum Bootstrap v4.

.box-sizing(@box-model) {
  -webkit-box-sizing: @box-model; // Safari <= 5
     -moz-box-sizing: @box-model; // Firefox <= 19
          box-sizing: @box-model;
}

Rounded ces kaum

Niaj hnub no tag nrho cov niaj hnub browsers txhawb cov khoom tsis yog ua ntej border-radius. Xws li, tsis muaj kev .border-radius()sib xyaw, tab sis Bootstrap suav nrog shortcuts kom nrawm nrawm ob lub ces kaum ntawm ib sab ntawm ib qho khoom.

.border-top-radius(@radius) {
  border-top-right-radius: @radius;
   border-top-left-radius: @radius;
}
.border-right-radius(@radius) {
  border-bottom-right-radius: @radius;
     border-top-right-radius: @radius;
}
.border-bottom-radius(@radius) {
  border-bottom-right-radius: @radius;
   border-bottom-left-radius: @radius;
}
.border-left-radius(@radius) {
  border-bottom-left-radius: @radius;
     border-top-left-radius: @radius;
}

Box (Drop) ntxoov ntxoo

Yog tias koj lub hom phiaj cov neeg tuaj saib yog siv qhov tseeb thiab zoo tshaj plaws browsers thiab cov khoom siv, nco ntsoov tsuas yog siv cov box-shadowcuab yeej ntawm nws tus kheej. Yog tias koj xav tau kev txhawb nqa rau cov laus hauv Android (pre-v4) thiab iOS pab kiag li lawm (pre-iOS 5), siv cov khoom siv tsis txaus los khaws cov -webkitlus ua ntej.

Lub mixin yog deprecated li ntawm v3.1.0, txij li thaum Bootstrap tsis officially txhawb lub outdated platforms uas tsis txhawb tus qauv khoom. Txhawm rau khaws rov qab-kev sib raug zoo, Bootstrap yuav txuas ntxiv siv cov mixin sab hauv kom txog thaum Bootstrap v4.

Nco ntsoov siv rgba()cov xim hauv koj lub thawv duab ntxoov ntxoo kom lawv sib xyaw ua ke zoo li ua tau nrog keeb kwm yav dhau.

.box-shadow(@shadow: 0 1px 3px rgba(0,0,0,.25)) {
  -webkit-box-shadow: @shadow; // iOS <4.3 & Android <4.1
          box-shadow: @shadow;
}

Kev hloov pauv

Ntau mixins rau yooj. Teem tag nrho cov ntaub ntawv hloov pauv nrog ib qho, lossis qhia qhov ncua sij hawm thiab ncua sij hawm raws li xav tau.

Cov mixins yog deprecated li ntawm v3.2.0, nrog rau kev taw qhia ntawm Autoprefixer. Txhawm rau khaws rov qab-kev sib raug zoo, Bootstrap yuav txuas ntxiv siv cov mixins sab hauv kom txog thaum Bootstrap v4.

.transition(@transition) {
  -webkit-transition: @transition;
          transition: @transition;
}
.transition-property(@transition-property) {
  -webkit-transition-property: @transition-property;
          transition-property: @transition-property;
}
.transition-delay(@transition-delay) {
  -webkit-transition-delay: @transition-delay;
          transition-delay: @transition-delay;
}
.transition-duration(@transition-duration) {
  -webkit-transition-duration: @transition-duration;
          transition-duration: @transition-duration;
}
.transition-timing-function(@timing-function) {
  -webkit-transition-timing-function: @timing-function;
          transition-timing-function: @timing-function;
}
.transition-transform(@transition) {
  -webkit-transition: -webkit-transform @transition;
     -moz-transition: -moz-transform @transition;
       -o-transition: -o-transform @transition;
          transition: transform @transition;
}

Kev hloov pauv

Tig, ntsuas, txhais (tsav), lossis skew ib yam khoom.

Cov mixins yog deprecated li ntawm v3.2.0, nrog rau kev taw qhia ntawm Autoprefixer. Txhawm rau khaws rov qab-kev sib raug zoo, Bootstrap yuav txuas ntxiv siv cov mixins sab hauv kom txog thaum Bootstrap v4.

.rotate(@degrees) {
  -webkit-transform: rotate(@degrees);
      -ms-transform: rotate(@degrees); // IE9 only
          transform: rotate(@degrees);
}
.scale(@ratio; @ratio-y...) {
  -webkit-transform: scale(@ratio, @ratio-y);
      -ms-transform: scale(@ratio, @ratio-y); // IE9 only
          transform: scale(@ratio, @ratio-y);
}
.translate(@x; @y) {
  -webkit-transform: translate(@x, @y);
      -ms-transform: translate(@x, @y); // IE9 only
          transform: translate(@x, @y);
}
.skew(@x; @y) {
  -webkit-transform: skew(@x, @y);
      -ms-transform: skewX(@x) skewY(@y); // See https://github.com/twbs/bootstrap/issues/4885; IE9+
          transform: skew(@x, @y);
}
.translate3d(@x; @y; @z) {
  -webkit-transform: translate3d(@x, @y, @z);
          transform: translate3d(@x, @y, @z);
}

.rotateX(@degrees) {
  -webkit-transform: rotateX(@degrees);
      -ms-transform: rotateX(@degrees); // IE9 only
          transform: rotateX(@degrees);
}
.rotateY(@degrees) {
  -webkit-transform: rotateY(@degrees);
      -ms-transform: rotateY(@degrees); // IE9 only
          transform: rotateY(@degrees);
}
.perspective(@perspective) {
  -webkit-perspective: @perspective;
     -moz-perspective: @perspective;
          perspective: @perspective;
}
.perspective-origin(@perspective) {
  -webkit-perspective-origin: @perspective;
     -moz-perspective-origin: @perspective;
          perspective-origin: @perspective;
}
.transform-origin(@origin) {
  -webkit-transform-origin: @origin;
     -moz-transform-origin: @origin;
      -ms-transform-origin: @origin; // IE9 only
          transform-origin: @origin;
}

Animations

Ib qho mixin rau kev siv tag nrho ntawm CSS3 cov cuab yeej animation hauv ib qho kev tshaj tawm thiab lwm cov mixins rau cov khoom ntiag tug.

Cov mixins yog deprecated li ntawm v3.2.0, nrog rau kev taw qhia ntawm Autoprefixer. Txhawm rau khaws rov qab-kev sib raug zoo, Bootstrap yuav txuas ntxiv siv cov mixins sab hauv kom txog thaum Bootstrap v4.

.animation(@animation) {
  -webkit-animation: @animation;
          animation: @animation;
}
.animation-name(@name) {
  -webkit-animation-name: @name;
          animation-name: @name;
}
.animation-duration(@duration) {
  -webkit-animation-duration: @duration;
          animation-duration: @duration;
}
.animation-timing-function(@timing-function) {
  -webkit-animation-timing-function: @timing-function;
          animation-timing-function: @timing-function;
}
.animation-delay(@delay) {
  -webkit-animation-delay: @delay;
          animation-delay: @delay;
}
.animation-iteration-count(@iteration-count) {
  -webkit-animation-iteration-count: @iteration-count;
          animation-iteration-count: @iteration-count;
}
.animation-direction(@direction) {
  -webkit-animation-direction: @direction;
          animation-direction: @direction;
}

Opacity

Teem lub opacity rau tag nrho cov browsers thiab muab ib tug filterpoob rau IE8.

.opacity(@opacity) {
  opacity: @opacity;
  // IE8 filter
  @opacity-ie: (@opacity * 100);
  filter: ~"alpha(opacity=@{opacity-ie})";
}

Placeholder text

Muab cov ntsiab lus rau daim ntawv tswj hauv txhua qhov chaw.

.placeholder(@color: @input-color-placeholder) {
  &::-moz-placeholder           { color: @color; } // Firefox
  &:-ms-input-placeholder       { color: @color; } // Internet Explorer 10+
  &::-webkit-input-placeholder  { color: @color; } // Safari and Chrome
}

Cov kab

Tsim cov kab ntawm CSS hauv ib lub caij.

.content-columns(@width; @count; @gap) {
  -webkit-column-width: @width;
     -moz-column-width: @width;
          column-width: @width;
  -webkit-column-count: @count;
     -moz-column-count: @count;
          column-count: @count;
  -webkit-column-gap: @gap;
     -moz-column-gap: @gap;
          column-gap: @gap;
}

Gradints

Yooj yim tig ob xim rau hauv ib qho gradient tom qab. Tau txais kev tshaj lij thiab teeb tsa kev taw qhia, siv peb xim, lossis siv qhov radial gradient. Nrog ib tug mixin koj tau txais tag nrho cov prefixed syntaxes koj yuav xav tau.

#gradient > .vertical(#333; #000);
#gradient > .horizontal(#333; #000);
#gradient > .radial(#333; #000);

Koj tuaj yeem hais qhia lub kaum sab xis ntawm tus qauv ob-xim, linear gradient:

#gradient > .directional(#333; #000; 45deg);

Yog hais tias koj xav tau ib tug barber-stripe style gradient, uas yog ib qho yooj yim, ib yam nkaus thiab. Tsuas yog qhia ib qho xim xwb thiab peb mam li overlay ib kab dawb translucent.

#gradient > .striped(#333; 45deg);

Nce lub ante thiab siv peb xim xwb. Teem thawj xim, xim thib ob, xim xim xim thib ob (ib feem pua ​​​​tus nqi zoo li 25%), thiab xim thib peb nrog cov mixins:

#gradient > .vertical-three-colors(#777; #333; 25%; #000);
#gradient > .horizontal-three-colors(#777; #333; 25%; #000);

Tau taub hau! Yog tias koj puas xav tau tshem tawm qhov gradient, nco ntsoov tshem tawm ib qho IE tshwj xeeb uas filterkoj tau ntxiv. Koj tuaj yeem ua qhov ntawd los ntawm kev siv cov .reset-filter()mixin ib sab background-image: none;.

Utility mixins

Utility mixins yog cov mixins uas sib txuas lwm yam tsis cuam tshuam nrog CSS cov khoom kom ua tiav lub hom phiaj tshwj xeeb lossis ua haujlwm.

Clearfix

Tsis nco qab ntxiv class="clearfix"rau txhua lub ntsiab lus thiab hloov cov .clearfix()mixin qhov tsim nyog. Siv micro clearfix los ntawm Nicolas Gallagher .

// Mixin
.clearfix() {
  &:before,
  &:after {
    content: " ";
    display: table;
  }
  &:after {
    clear: both;
  }
}

// Usage
.container {
  .clearfix();
}

Kab rov tav centering

Ceev nrooj nruab ib qho hauv nws niam nws txiv. Yuav tsum tau widthlos yog max-widthyuav tsum tau teem.

// Mixin
.center-block() {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

// Usage
.container {
  width: 940px;
  .center-block();
}

Sizing pab

Qhia qhov ntev ntawm ib yam khoom yooj yim dua.

// Mixins
.size(@width; @height) {
  width: @width;
  height: @height;
}
.square(@size) {
  .size(@size; @size);
}

// Usage
.image { .size(400px; 300px); }
.avatar { .square(48px); }

Resizable cov ntaub ntawv

Yooj yim configure cov kev xaiv resize rau tej textarea, los yog lwm yam khoom. Defaults rau ib txwm browser tus cwj pwm ( both).

.resizable(@direction: both) {
  // Options: horizontal, vertical, both
  resize: @direction;
  // Safari fix
  overflow: auto;
}

Txiav cov ntawv

Yooj yim txiav cov ntawv nrog ib qho ellipsis nrog ib qho mixin. Yuav tsum muaj lub hauv paus los blockyog inline-blockqib.

// Mixin
.text-overflow() {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// Usage
.branch-name {
  display: inline-block;
  max-width: 200px;
  .text-overflow();
}

Retina duab

Qhia ob txoj hauv kev duab thiab @ 1x duab qhov ntev, thiab Bootstrap yuav muab cov lus nug @2x. Yog tias koj muaj ntau cov duab los ua haujlwm, xav txog kev sau koj cov duab retina CSS manually hauv ib qho lus nug xov xwm.

.img-retina(@file-1x; @file-2x; @width-1x; @height-1x) {
  background-image: url("@{file-1x}");

  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and (     -o-min-device-pixel-ratio: 2/1),
  only screen and (        min-device-pixel-ratio: 2),
  only screen and (                min-resolution: 192dpi),
  only screen and (                min-resolution: 2dppx) {
    background-image: url("@{file-2x}");
    background-size: @width-1x @height-1x;
  }
}

// Usage
.jumbotron {
  .img-retina("/img/bg-1x.png", "/img/bg-2x.png", 100px, 100px);
}

Siv Sass

Thaum Bootstrap yog tsim los ntawm Tsawg, nws kuj muaj qhov chaw nres nkoj Sass . Peb tuav nws hauv ib qho chaw khaws cia GitHub cais thiab tuav cov kev hloov tshiab nrog tsab ntawv hloov dua siab tshiab.

Dab tsi suav nrog

Txij li thaum qhov chaw nres nkoj Sass muaj ib qho repo cais thiab ua hauj lwm rau cov neeg tuaj saib sib txawv me ntsis, cov ntsiab lus ntawm qhov project txawv heev los ntawm lub ntsiab Bootstrap project. Qhov no ua kom qhov chaw nres nkoj Sass yog sib xws nrog ntau Sass-based systems li sai tau.

Txoj kev Kev piav qhia
lib/ Ruby lub pov haum code (Sass configuration, Rails thiab Compass integrations)
tasks/ Hloov cov ntawv sau (tig qis qis rau Sass)
test/ Kev ntsuam xyuas muab tso ua ke
templates/ Compass pob manifest
vendor/assets/ Sass, JavaScript, thiab font files
Rakefile Cov haujlwm sab hauv, xws li rake thiab hloov pauv

Mus ntsib Sass chaw nres nkoj GitHub chaw cia khoom kom pom cov ntaub ntawv no ua haujlwm.

Kev teeb tsa

Yog xav paub ntxiv txog yuav ua li cas rau nruab thiab siv Bootstrap rau Sass, sab laj GitHub repository readme . Nws yog qhov tseeb tshaj plaws thiab suav nrog cov ntaub ntawv siv nrog Rails, Compass, thiab cov haujlwm Sass txheem.

Bootstrap rau Sass