Zosokoneza
Breakpoints ndi makulidwe osinthika makonda omwe amatsimikizira momwe masanjidwe anu omvera amayendera pazida zonse kapena kukula kwa malo owonera mu Bootstrap.
Malingaliro apakati
-
Breakpoints ndiye zomangira zamapangidwe omvera. Gwiritsani ntchito kuwongolera nthawi yomwe masanjidwe anu angasinthidwe pamalo enaake kapena kukula kwa chipangizo.
-
Gwiritsani ntchito mafunso atolankhani kuti mupange CSS yanu ndi breakpoint. Media queries ndi gawo la CSS lomwe limakulolani kuti mugwiritse ntchito masitayelo molingana ndi msakatuli ndi magawo ogwiritsira ntchito. Nthawi zambiri timagwiritsa ntchito
min-width
pamafunso athu azama media. -
Mafoni a m'manja choyamba, mapangidwe omvera ndicho cholinga. Bootstrap's CSS imafuna kugwiritsa ntchito masitayelo ochepa chabe kuti masanjidwewo agwire ntchito pamalo aang'ono kwambiri, kenako ndikuyika masitayelo kuti asinthe kapangidwe ka zida zazikulu. Izi zimakhathamiritsa CSS yanu, zimakulitsa nthawi yoperekera, komanso zimapereka chidziwitso chabwino kwa alendo anu.
Ma breakpoints omwe alipo
Bootstrap imaphatikizapo magawo asanu ndi limodzi okhazikika, omwe nthawi zina amatchedwa ma grid tiers , kuti amange momvera. Zosokoneza izi zitha kusinthidwa makonda ngati mukugwiritsa ntchito mafayilo athu a Sass.
Breakpoint | Class infix | Makulidwe |
---|---|---|
X-Wamng'ono | Palibe | <576px |
Wamng'ono | sm |
≥576px |
Wapakati | md |
≥768px |
Chachikulu | lg |
≥992px |
Chachikulu kwambiri | xl |
≥1200px |
Zowonjezera zazikulu | xxl |
≥1400px |
Podukapo aliyense amasankhidwa kuti azigwira bwino makontena omwe m'lifupi mwake ndi machulukitsidwe 12. Ma Breakpoints amayimiranso kagawo kakang'ono kachida kachipangizo kofanana ndi makulidwe owonera—samayang'ana kachipangizo kalikonse kogwiritsa ntchito kapena chipangizo chilichonse. M'malo mwake, maguluwa amapereka maziko olimba komanso osasinthasintha kuti amangepo pafupifupi chipangizo chilichonse.
Malo opumirawa amatha kusinthidwa mwamakonda kudzera pa Sass—muwapeza pamapu a Sass patsamba lathu _variables.scss
.
$grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1400px
);
Kuti mumve zambiri ndi zitsanzo zamomwe mungasinthire mamapu athu a Sass ndi zosintha, chonde onani gawo la Sass la zolembedwa za Gridi .
Mafunso pa media
Popeza Bootstrap idapangidwa kuti ikhale yam'manja poyamba, timagwiritsa ntchito mafunso angapo azama TV kuti tipange zopumira zomveka pamasanjidwe athu ndi mawonekedwe athu. Malo opumirawa nthawi zambiri amatengera kukula kwa mawonekedwe ocheperako ndipo amatilola kuti tiwonjeze zinthu momwe mawonekedwe akusintha.
Min-width
Bootstrap imagwiritsa ntchito mndandanda wamafunso otsatirawa - kapena ma breakpoints - m'mafayilo athu a Sass pamawonekedwe athu, grid system, ndi zida.
// 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;
}
}
Zosakaniza za Sass izi zimamasulira mu CSS yathu yopangidwa pogwiritsa ntchito zomwe zafotokozedwa muzosintha zathu za Sass. Mwachitsanzo:
// 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-width
Nthawi zina timagwiritsa ntchito mafunso azama TV omwe amapita mbali ina (kukula kwa skrini kapena kucheperako ):
// 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;
}
}
Zosakaniza izi zimatenga malo omwe adalengezedwa, .02px
kuwachotsa, ndikuwagwiritsa ntchito ngati max-width
mfundo zathu. Mwachitsanzo:
// 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
min-
prefixes max-
ndi mawonedwe okhala ndi m'lifupi mwake (omwe amatha kuchitika pazinthu zina pazida zapamwamba za dpi, mwachitsanzo) pogwiritsa ntchito milingo molondola kwambiri.
Malo amodzi okha
Palinso mafunso atolankhani ndi zosakaniza zolozera gawo limodzi la makulidwe a skrini pogwiritsa ntchito kutalika kocheperako komanso kopitilira muyeso.
@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) { ... }
Mwachitsanzo @include media-breakpoint-only(md) { ... }
, zitha kukhala:
@media (min-width: 768px) and (max-width: 991.98px) { ... }
Pakati pa breakpoints
Momwemonso, mafunso azama media atha kufalikira m'magawo angapo:
@include media-breakpoint-between(md, xl) { ... }
Zomwe zimabweretsa:
// Example
// Apply styles starting from medium devices and up to extra large devices
@media (min-width: 768px) and (max-width: 1199.98px) { ... }