in English

Txheej txheem cej luam

Cov Cheebtsam thiab cov kev xaiv rau kev tso tawm koj qhov haujlwm Bootstrap, suav nrog cov ntim ntim, lub kaw lus muaj zog, cov khoom siv xov xwm hloov tau yooj yim, thiab cov chav kawm siv hluav taws xob.

Ntim

Cov thawv ntim khoom yog cov txheej txheem yooj yim tshaj plaws hauv Bootstrap thiab yuav tsum tau siv thaum siv peb cov kab sib chaws default . Cov thawv ntim tau siv los ntim, ncoo, thiab (qee zaum) nruab nrab cov ntsiab lus hauv lawv. Thaum cov thawv tuaj yeem ua zes, feem ntau layouts tsis xav tau lub thawv nested.

Bootstrap los nrog peb lub thawv sib txawv:

  • .container, uas teev ib qho max-widthntawm txhua qhov kev cuam tshuam
  • .container-fluid, uas yog width: 100%nyob rau hauv tag nrho cov breakpoints
  • .container-{breakpoint}, uas yog width: 100%kom txog rau thaum lub sij hawm breakpoint

Cov lus hauv qab no qhia txog yuav ua li cas txhua lub thawv max-widthsib piv rau qhov qub .containerthiab .container-fluidhla txhua qhov chaw tawg.

Saib lawv hauv kev nqis tes ua thiab muab piv rau hauv peb daim phiaj piv txwv .

Ntxiv me me
<576px
Me me
≥576px
Nruab nrab
≥768px
Loj
≥992px
Ntxiv loj
≥1200px
.container 100% 5 40px 7 20px 9 60px 1 140px
.container-sm 100% 5 40px 7 20px 9 60px 1 140px
.container-md 100% 100% 7 20px 9 60px 1 140px
.container-lg 100% 100% 100% 9 60px 1 140px
.container-xl 100% 100% 100% 100% 1 140px
.container-fluid 100% 100% 100% 100% 100%

Txhua-hauv-ib

Peb cov .containerchav kawm ua ntej yog lub thawv teb, qhov dav-ntev, txhais tau tias nws cov max-widthkev hloov pauv ntawm txhua qhov chaw tawg.

<div class="container">
  <!-- Content here -->
</div>

Kua dej

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

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

Teb

Cov thawv teb yog tshiab hauv Bootstrap v4.4. Lawv tso cai rau koj qhia ib chav kawm uas yog 100% dav kom txog rau thaum lub sij hawm breakpoint tau mus txog, tom qab uas peb thov max-widths rau txhua qhov siab dua breakpoints. Piv txwv li, .container-smyog 100% dav pib kom txog rau thaum lub smbreakpoint mus txog, qhov twg nws yuav scale nrog md, lg, thiab xl.

<div class="container-sm">100% wide until small breakpoint</div>
<div class="container-md">100% wide until medium breakpoint</div>
<div class="container-lg">100% wide until large breakpoint</div>
<div class="container-xl">100% wide until extra large breakpoint</div>

Teb breakpoints

Txij li thaum Bootstrap yog tsim los ua mobile ua ntej, peb siv ib tug puv tes ntawm xov xwm queries los tsim kom paub meej breakpoints rau peb layouts thiab interfaces. Cov breakpoints no feem ntau yog raws li qhov tsawg kawg nkaus saib qhov dav dav thiab tso cai rau peb los ntsuas cov ntsiab lus raws li qhov pom qhov hloov pauv.

Bootstrap feem ntau siv cov lus nug hauv qab no - lossis cov ntsiab lus tawg - hauv peb cov ntaub ntawv Sass rau peb qhov kev teeb tsa, kab sib chaws, thiab cov khoom.

// Extra small devices (portrait phones, less than 576px)
// No media query for `xs` since this is the default in Bootstrap

// Small devices (landscape phones, 576px and up)
@media (min-width: 576px) { ... }

// Medium devices (tablets, 768px and up)
@media (min-width: 768px) { ... }

// Large devices (desktops, 992px and up)
@media (min-width: 992px) { ... }

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

Txij li thaum peb sau peb qhov chaw CSS hauv Sass, tag nrho peb cov lus nug xov xwm muaj nyob ntawm Sass mixins:

// No media query necessary for xs breakpoint as it's effectively `@media (min-width: 0) { ... }`
@include media-breakpoint-up(sm) { ... }
@include media-breakpoint-up(md) { ... }
@include media-breakpoint-up(lg) { ... }
@include media-breakpoint-up(xl) { ... }

// Example: Hide starting at `min-width: 0`, and then show at the `sm` breakpoint
.custom-class {
  display: none;
}
@include media-breakpoint-up(sm) {
  .custom-class {
    display: block;
  }
}

Peb qee zaus siv cov lus nug xov xwm uas mus rau lwm qhov kev taw qhia (qhov muab lub vijtsam loj lossis me dua ):

// Extra small devices (portrait phones, less than 576px)
@media (max-width: 575.98px) { ... }

// Small devices (landscape phones, less than 768px)
@media (max-width: 767.98px) { ... }

// Medium devices (tablets, less than 992px)
@media (max-width: 991.98px) { ... }

// Large devices (desktops, less than 1200px)
@media (max-width: 1199.98px) { ... }

// Extra large devices (large desktops)
// No media query since the extra-large breakpoint has no upper bound on its width
Nco ntsoov tias txij li cov browsers tam sim no tsis txhawb ntau cov ntsiab lus nug , peb ua haujlwm nyob ib puag ncig cov kev txwv ntawm min-thiab max-ua ntej thiab cov chaw saib nrog qhov dav dav (uas tuaj yeem tshwm sim nyob rau qee yam ntawm cov khoom siv high-dpi, piv txwv li) los ntawm kev siv cov txiaj ntsig siab dua rau cov kev sib piv no. .

Ib zaug ntxiv, cov lus nug xov xwm no kuj muaj nyob ntawm Sass mixins:

@include media-breakpoint-down(xs) { ... }
@include media-breakpoint-down(sm) { ... }
@include media-breakpoint-down(md) { ... }
@include media-breakpoint-down(lg) { ... }
// No media query necessary for xl breakpoint as it has no upper bound on its width

// Example: Style from medium breakpoint and down
@include media-breakpoint-down(md) {
  .custom-class {
    display: block;
  }
}

Kuj tseem muaj cov lus nug xov xwm thiab cov mixins rau lub hom phiaj ib ntu ntawm qhov screen loj siv qhov tsawg kawg nkaus thiab qhov siab tshaj plaws breakpoint widths.

// Extra small devices (portrait phones, less than 576px)
@media (max-width: 575.98px) { ... }

// Small devices (landscape phones, 576px and up)
@media (min-width: 576px) and (max-width: 767.98px) { ... }

// Medium devices (tablets, 768px and up)
@media (min-width: 768px) and (max-width: 991.98px) { ... }

// Large devices (desktops, 992px and up)
@media (min-width: 992px) and (max-width: 1199.98px) { ... }

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

Cov lus nug xov xwm no kuj muaj nyob ntawm Sass mixins:

@include media-breakpoint-only(xs) { ... }
@include media-breakpoint-only(sm) { ... }
@include media-breakpoint-only(md) { ... }
@include media-breakpoint-only(lg) { ... }
@include media-breakpoint-only(xl) { ... }

Ib yam li ntawd, cov lus nug xov xwm tuaj yeem nthuav dav ntau qhov dav dav:

// Example
// Apply styles starting from medium devices and up to extra large devices
@media (min-width: 768px) and (max-width: 1199.98px) { ... }

Sass mixin rau lub hom phiaj tib lub vijtsam loj yuav yog:

@include media-breakpoint-between(md, xl) { ... }

Z-index

Ob peb Bootstrap Cheebtsam siv z-index, CSS cov cuab yeej uas pab tswj kev teeb tsa los ntawm kev muab peb axis los npaj cov ntsiab lus. Peb siv lub default z-index scale nyob rau hauv Bootstrap uas yog tsim los kom zoo txheej navigation, tooltips thiab popovers, modals, thiab ntau dua.

Cov nqi siab dua no pib ntawm tus lej tsis txaus ntseeg, siab thiab tshwj xeeb txaus kom tsis txhob muaj kev tsis sib haum xeeb. Peb xav tau cov txheej txheem txheej txheem ntawm cov no thoob plaws peb cov txheej txheem - cov lus qhia, popovers, navbars, dropdowns, modals - yog li peb tuaj yeem ua raws li kev coj cwj pwm. Tsis muaj laj thawj peb tsis tuaj yeem siv 100+ lossis 500+.

Peb tsis txhawb kom customization ntawm tus kheej qhov tseem ceeb no; Yog tias koj hloov ib qho, koj yuav xav tau hloov lawv txhua tus.

$zindex-dropdown:          1000 !default;
$zindex-sticky:            1020 !default;
$zindex-fixed:             1030 !default;
$zindex-modal-backdrop:    1040 !default;
$zindex-modal:             1050 !default;
$zindex-popover:           1060 !default;
$zindex-tooltip:           1070 !default;

Txhawm rau tswj cov ciam teb sib tshooj hauv cov khoom (piv txwv li, cov nyees khawm thiab cov khoom siv hauv pawg tswv yim), peb siv tus lej qis tus lej z-indexntawm 1, 2, thiab 3rau lub neej ntawd, txav mus, thiab lub xeev nquag. Ntawm hover/focus/active, peb nqa ib lub ntsiab rau pem hauv ntej nrog tus nqi siab dua z-indexlos qhia lawv ciam teb ntawm cov kwv tij.