Twe kɔ emu nsɛm atitiriw no so Twe kɔ docs navigation so
in English

Nneɛma a wɔde gyae

Breakpoints yɛ ntrɛwmu a wotumi sesa a ɛkyerɛ sɛnea wo mmuae nhyehyɛe no yɛ n’ade wɔ mfiri anaa viewport akɛse nyinaa mu wɔ Bootstrap mu.

Nsusuwii atitiriw

  • Breakpoints yɛ adansi nneɛma a wɔde yɛ nhyehyɛe a ɛyɛ adwuma yiye. Fa di dwuma fa hwɛ bere a wobetumi asakra wo nhyehyɛe no wɔ viewport anaa device kɛse pɔtee bi so.

  • Fa media nsɛmmisa di dwuma fa architect wo CSS no denam breakpoint so. Media nsɛmmisa yɛ CSS no fã bi a ɛma wo kwan ma wode tebea horow a egyina browser ne operating system parameters ahorow so di dwuma wɔ tebea bi mu. Yɛtaa de di dwuma min-widthkɛse wɔ yɛn nsɛm ho amanneɛbɔ ho nsɛmmisa mu.

  • Mobile kan, mmuae design ne botae no. Bootstrap CSS botae ne sɛ ɛde bare minimum of styles bedi dwuma de ama layout bi ayɛ adwuma wɔ breakpoint ketewaa bi so, na afei layers wɔ styles so de asiesie saa design no ama mfiri akɛse. Wei ma wo CSS yɛ papa, ɛma rendering bere tu mpɔn, na ɛma osuahu kɛse ma wo nsrahwɛfo.

Nneɛma a wɔde bebubu a ɛwɔ hɔ

Bootstrap no ka default breakpoints nsia, ɛtɔ da bi a wɔfrɛ no grid tiers , ma ɔdan a ɛyɛ mmuaeɛ. Saa breakpoints yi betumi ayɛ nea wopɛ sɛ wode yɛn source Sass fael ahorow no redi dwuma a.

Breakpoint a ɛwɔ hɔ Adesuakuw infix Nsusuwii ahorow
X-Nketewa Ɛnyɛ ebiara <576px na ɛwɔ hɔ
Ketewa sm ≥576px na ɛyɛ
Kwan md ≥768px na ɛyɛ
Kakraa lg ≥992px na ɛyɛ
Nneɛma akɛse a ɛboro so xl ≥1200px na ɛyɛ
Extra extra kɛse xxl ≥1400px na ɛyɛ

Wɔpaw breakpoint biara sɛ wɔde bɛkura containers a ne tɛtrɛtɛ yɛ mpɛn pii 12 no mu ahotɔ mu. Breakpoints nso yɛ mfiri akɛse ne viewport nsusuwii a wɔtaa de di dwuma no fã ketewaa bi ananmusifo —ɛnyɛ nea wɔde wɔn ani si so pɔtee biara a wɔde di dwuma anaa mfiri biara so. Mmom no, range ahorow no ma wonya fapem a ɛyɛ den na ɛkɔ so daa a ɛkame ayɛ sɛ wɔde besi so ama mfiri biara.

Saa breakpoints yi yɛ customizable via Sass —wobɛhunu wɔ Sass map mu wɔ yɛn _variables.scssstylesheet no mu.

$grid-breakpoints: (
  xs: 0,
  sm: 576px,
  md: 768px,
  lg: 992px,
  xl: 1200px,
  xxl: 1400px
);

Sɛ wopɛ nsɛm pii ne nhwɛsoɔ a ɛfa sɛdeɛ yɛbɛsesa yɛn Sass maps ne variables a, yɛsrɛ wo hwɛ Sass ɔfa a ɛwɔ Grid nkrataa no mu .

Nsɛm ho amanneɛbɔfo nsɛmmisa

Esiane sɛ wɔayɛ Bootstrap sɛ ɛnyɛ mobile kan nti, yɛde media nsɛmmisa kakraa bi di dwuma de yɛ breakpoints a ntease wom ma yɛn layouts ne interfaces. Saa breakpoints yi gyina viewport widths a ɛsua koraa so na ɛma yɛn kwan ma yɛ scale up elements bere a viewport no sesa no.

Min-trɛw

Bootstrap de media asɛmmisa kwan a edidi so yi di dwuma titiriw—anaasɛ breakpoints—wɔ yɛn source Sass fael ahorow no mu ma yɛn nhyehyɛe, grid nhyehyɛe, ne nneɛma a ɛwom no.

// Source 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) { ... }
@include media-breakpoint-up(xxl) { ... }

// Usage

// 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;
  }
}

Saa Sass mixins yi kyerɛ ase wɔ yɛn CSS a wɔaboaboa ano no mu denam values ​​a wɔabɔ ho dawuru wɔ yɛn Sass variables no mu no so. Nhwɛsoɔ:

// X-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) { ... }

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

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

Max-trɛw

Ɛtɔ mmere bi a yɛde media nsɛmmisa a ɛkɔ ɔkwan foforo so (screen size a wɔde ama anaa nea ɛsua ) di dwuma:

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

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

Saa mixins yi fa saa breakpoints a wɔabɔ ho dawuru no, yi .02pxfi mu, na wɔde di dwuma sɛ yɛn max-widthgyinapɛn ahorow. Nhwɛsoɔ:

// X-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) { ... }

// X-Large devices (large desktops, less than 1400px)
@media (max-width: 1399.98px) { ... }

// XX-Large devices (larger desktops)
// No media query since the xxl breakpoint has no upper bound on its width
Dɛn nti na ɛsɛ sɛ woyi .02px fi mu? Browsers don’t currently support range context queries , enti yɛyɛ adwuma twa anohyeto ahorow a ɛwɔ min-ne max-prefixes ne viewports a ɛwɔ fractional widths (a ebetumi aba wɔ tebea horow bi mu wɔ high-dpi mfiri ahorow so, sɛ nhwɛso no) denam values ​​a ɛwɔ pɛpɛɛpɛyɛ a ɛkorɔn a yɛde bedi dwuma no so.

Breakpoint biako pɛ

Afei nso media nsɛmmisa ne mixins wɔ hɔ a wɔde si screen akɛseɛ fã baako a wɔde breakpoint widths a ɛsua ne kɛseɛ di dwuma.

@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) { ... }
@include media-breakpoint-only(xxl) { ... }

Sɛ nhwɛso no, @include media-breakpoint-only(md) { ... }will no de bɛba : .

@media (min-width: 768px) and (max-width: 991.98px) { ... }

Wɔ breakpoints ntam

Saa ara nso na media nsɛmmisa betumi atrɛw breakpoint ntrɛwmu pii:

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

Nea ɛde ba ne sɛ:

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