Nsɛm a Wɔaka abom
Nneɛma ne akwan a wobɛfa so asiesie wo Bootstrap adwuma no, a nea ɛka ho ne wrapping containers, grid nhyehyɛe a ahoɔden wom, media ade a ɛyɛ mmerɛw, ne utility classes a ɛyɛ mmuae.
Nneɛma a wɔde gu mu
Containers yɛ nhyehyɛe element titiriw wɔ Bootstrap mu na ɛho hia bere a wode yɛn default grid nhyehyɛe no redi dwuma no . Wɔde nsukorade di dwuma de kura, pad, na (ɛtɔ mmere bi a) nneɛma a ɛwɔ mu no mfinimfini. Bere a wobetumi ayɛ nkorabata no nest no, nhyehyɛe dodow no ara nhia sɛ wɔde nkorabata a wɔde ahyɛ mu.
Bootstrap no de nneɛma ahorow abiɛsa a wɔde gu mu ba:
.container
, a ɛde a si hɔmax-width
wɔ mmuae biara mu breakpoint.container-fluid
, a ɛyɛwidth: 100%
breakpoints biara mu.container-{breakpoint}
, a ɛyɛwidth: 100%
kosi sɛ wobegyae bere a wɔakyerɛ no
Table a ɛwɔ aseɛ ha yi kyerɛ sɛdeɛ container biara max-width
de toto mfitiaseɛ no .container
ho ne .container-fluid
breakpoint biara so.
Hwɛ wɔn wɔ adeyɛ mu na fa toto ho wɔ yɛn Grid nhwɛso no mu .
Nneɛma nketenkete a ɛboro so <576px |
Nketewa a ɛyɛ ≥576px |
Mfinimfini ≥768px |
Ɔkɛseɛ ≥992px |
Ɔkɛseɛ a ɛboro so ≥1200px |
|
---|---|---|---|---|---|
.container |
100% na ɛwɔ hɔ. | 540px na ɛyɛ | 720px na ɛyɛ | 960px na ɛyɛ | 1140px na ɛyɛ |
.container-sm |
100% na ɛwɔ hɔ. | 540px na ɛyɛ | 720px na ɛyɛ | 960px na ɛyɛ | 1140px na ɛyɛ |
.container-md |
100% na ɛwɔ hɔ. | 100% na ɛwɔ hɔ. | 720px na ɛyɛ | 960px na ɛyɛ | 1140px na ɛyɛ |
.container-lg |
100% na ɛwɔ hɔ. | 100% na ɛwɔ hɔ. | 100% na ɛwɔ hɔ. | 960px na ɛyɛ | 1140px na ɛyɛ |
.container-xl |
100% na ɛwɔ hɔ. | 100% na ɛwɔ hɔ. | 100% na ɛwɔ hɔ. | 100% na ɛwɔ hɔ. | 1140px na ɛyɛ |
.container-fluid |
100% na ɛwɔ hɔ. | 100% na ɛwɔ hɔ. | 100% na ɛwɔ hɔ. | 100% na ɛwɔ hɔ. | 100% na ɛwɔ hɔ. |
Ne nyinaa-wɔ-baako mu
Yɛn default .container
class no yɛ mmuaeɛ, fixed-width container, a ɛkyerɛ ne max-width
nsakraeɛ wɔ breakpoint biara.
Nsudeɛ
Fa di dwuma .container-fluid
ma ade a ne tɛtrɛtɛ nyinaa, a ɛtrɛw hwɛbea no ntrɛwmu nyinaa.
Mmuae a wɔde ma
Responsive containers yɛ foforo wɔ Bootstrap v4.4 mu. Wɔma wo kwan ma wokyerɛ adesuakuw bi a ɛtrɛw 100% kosi sɛ wobedu breakpoint a wɔakyerɛ no ho, na ɛno akyi no yɛde max-width
s di dwuma ma breakpoints a ɛkorɔn no mu biara. Sɛ nhwɛso no, .container-sm
ɛyɛ 100% trɛw sɛ wobefi ase kosi sɛ wobedu sm
breakpoint no ho, baabi a ɛbɛkɔ soro denam md
, lg
, ne xl
.
Mmuae a wɔde gyae nneɛma
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 dodoɔ no ara na ɛma yɛn kwan ma yɛ scale up elements berɛ a viewport no sesa.
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.
Esiane sɛ yɛkyerɛw yɛn source CSS wɔ Sass mu nti, yɛn media nsɛmmisa nyinaa wɔ hɔ denam Sass mixins so:
Ɛ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:
Hyɛ no nsow sɛ esiane sɛ mprempren browser ahorow ntumi mmoa range context queries , 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) ho dwuma denam values a ɛwɔ pɛpɛɛpɛyɛ a ɛkorɔn a yɛde di dwuma ma saa ntotoho ahorow yi so .
Saa bere yi nso, saa media nsɛmmisa yi nso wɔ hɔ denam Sass mixins so:
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.
Saa media nsɛmmisa yi nso wɔ hɔ denam Sass mixins so:
Saa ara nso na media nsɛmmisa betumi atrɛw breakpoint ntrɛwmu pii:
Sass mixin a wɔde bɛto screen size range koro no ara so no bɛyɛ:
Z-index a ɛwɔ hɔ
Bootstrap afã horow pii de di dwuma z-index
, CSS agyapade a ɛboa ma wɔhwɛ nhyehyɛe so denam axis a ɛto so abiɛsa a wɔde ma de hyehyɛ nsɛm no so. Yɛde default z-index scale di dwuma wɔ Bootstrap mu a wɔayɛ sɛ ɛbɛma layer navigation, adwinnade ho nsɛm ne popovers, modals, ne nea ɛkeka ho yiye.
Saa gyinapɛn ahorow a ɛkorɔn yi fi ase wɔ dodow a wɔmpɛ so, a ɛkorɔn na ɛyɛ pɔtee sɛnea ɛbɛyɛ a ɛbɛyɛ papa sɛ wɔbɛkwati ntawntawdi. Yɛhia eyinom a wɔahyehyɛ no gyinapɛn wɔ yɛn afã horow a wɔayɛ no ntoatoaso no nyinaa mu —adwinnade ho nsɛm, popovers, navbars, dropdowns, modals —sɛnea ɛbɛyɛ a yebetumi ayɛ nea ɛfata wɔ nneyɛe no mu. Biribiara nni hɔ a enti anka yɛrentumi mfa 100
+ anaa 500
+ nni dwuma.
Yɛnhyɛ saa ankorankoro gyinapɛn ahorow yi a wɔbɛsakra no ho nkuran; sɛ wosakra biako a, ɛda adi sɛ ɛsɛ sɛ wosakra ne nyinaa.
Sɛ yɛbɛdi ahyeɛ a ɛka bom wɔ afã ahodoɔ no mu ho dwuma (sɛ nhwɛsoɔ no, bɔtɔn ne nsɛm a wɔde hyɛ mu wɔ nsɛm a wɔde hyɛ mu akuo mu), yɛde digit baako z-index
botaeɛ a ɛba fam a ɛyɛ 1
, 2
, ne 3
default, hover, ne active states di dwuma. Wɔ hover/focus/active so no, yɛde element pɔtee bi ba anim a ɛwɔ z-index
bo a ɛkorɔn de kyerɛ wɔn hye wɔ anuanom element ahorow no so.