Ħarsa ġenerali
Komponenti u għażliet għat-tqegħid tal-proġett Bootstrap tiegħek, inklużi kontenituri tat-tgeżwir, sistema ta 'grilja qawwija, oġġett tal-midja flessibbli, u klassijiet ta' utilità li jirrispondu.
Kontenituri
Il-kontenituri huma l-aktar element bażiku ta' tqassim f'Bootstrap u huma meħtieġa meta tuża s-sistema tal-grilja default tagħna . Kontenituri jintużaw biex ikun fihom, kuxxinett, u (xi kultant) iċċentra l-kontenut fihom. Filwaqt li l-kontenituri jistgħu jiġu mdaħħla, il-biċċa l-kbira tat-tqassim ma jeħtiġux kontenitur imdawwar.
Bootstrap jiġi bi tliet kontenituri differenti:
.container
, li jistabbilixxi amax-width
f'kull breakpoint reattiv.container-fluid
, li huwawidth: 100%
f'kull breakpoints.container-{breakpoint}
, li huwawidth: 100%
sal-punt ta 'waqfien speċifikat
It-tabella hawn taħt turi kif kull kontenitur max-width
iqabbel mal-oriġinal .container
u .container-fluid
fuq kull breakpoint.
Arahom fl-azzjoni u qabbluhom fl- eżempju tal-Grid tagħna .
Żgħir żejjed <576px |
Żgħar ≥576px |
Medju ≥768px |
Kbir ≥992px |
Kbir żejjed ≥1200px |
|
---|---|---|---|---|---|
.container |
100% | 540px | 720px | 960px | 1140px |
.container-sm |
100% | 540px | 720px | 960px | 1140px |
.container-md |
100% | 100% | 720px | 960px | 1140px |
.container-lg |
100% | 100% | 100% | 960px | 1140px |
.container-xl |
100% | 100% | 100% | 100% | 1140px |
.container-fluid |
100% | 100% | 100% | 100% | 100% |
Kollox f'daqqa
Il-klassi awtomatika tagħna .container
hija kontenitur reattiv u b'wisa 'fiss, jiġifieri l- max-width
bidliet tagħha f'kull breakpoint.
<div class="container">
<!-- Content here -->
</div>
Fluwidu
Uża .container-fluid
għal kontenitur wisa 'sħiħ, li jkopri l-wisa' kollu tal-viewport.
<div class="container-fluid">
...
</div>
Jirrispondi
Kontenituri li jirrispondu huma ġodda f'Bootstrap v4.4. Huma jippermettulek tispeċifika klassi li hija wiesgħa 100% sakemm jintlaħaq il-punt ta 'waqfien speċifikat, u wara napplikaw max-width
s għal kull wieħed mill-punti ta' waqfien ogħla. Pereżempju, .container-sm
hija wiesgħa 100% biex tibda sakemm sm
jintlaħaq il-punt ta 'waqfien, fejn se tiżdied b' md
, lg
, u 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>
Breakpoints li jirrispondu
Peress li Bootstrap huwa żviluppat biex ikun mobbli l-ewwel, nużaw numru żgħir ta ' mistoqsijiet tal-midja biex noħolqu breakpoints sensibbli għat-tqassim u l-interfaces tagħna. Dawn il-punti ta' waqfien huma l-aktar ibbażati fuq wisgħat minimi tal-viewport u jippermettulna nżidu l-elementi hekk kif tinbidel il-viewport.
Bootstrap primarjament juża l-firxiet ta 'mistoqsijiet tal-midja li ġejjin—jew breakpoints—fil-fajls Sass tas-sors tagħna għat-tqassim, is-sistema tal-grilja u l-komponenti tagħna.
// 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) { ... }
Peress li aħna niktbu s-CSS tas-sors tagħna f'Sass, il-mistoqsijiet kollha tal-midja tagħna huma disponibbli permezz ta' 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;
}
}
Kultant nużaw mistoqsijiet tal-midja li jmorru fid-direzzjoni l-oħra (id-daqs tal-iskrin mogħti jew iżgħar ):
// 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
min-
u max-
prefissi u viewports b'wisgħat frazzjonali (li jistgħu jseħħu taħt ċerti kundizzjonijiet fuq apparati b'dpi għolja, pereżempju) billi nużaw valuri bi preċiżjoni ogħla għal dawn il-paraguni. .
Għal darb'oħra, dawn il-mistoqsijiet tal-midja huma wkoll disponibbli permezz ta' 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;
}
}
Hemm ukoll mistoqsijiet tal-midja u mixins għall-mira ta 'segment wieħed ta' daqsijiet tal-iskrin bl-użu tal-wisa 'ta' breakpoint minimi u massimi.
// 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) { ... }
Dawn il-mistoqsijiet tal-midja huma wkoll disponibbli permezz ta' 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) { ... }
Bl-istess mod, il-mistoqsijiet tal-midja jistgħu jkopru diversi wisgħat ta' breakpoint:
// Example
// Apply styles starting from medium devices and up to extra large devices
@media (min-width: 768px) and (max-width: 1199.98px) { ... }
Il-mixin Sass biex timmira l-istess firxa tad-daqs tal-iskrin tkun:
@include media-breakpoint-between(md, xl) { ... }
Z-indiċi
Diversi komponenti Bootstrap jutilizzaw z-index
, il-proprjetà CSS li tgħin biex tikkontrolla t-tqassim billi tipprovdi t-tielet assi biex tirranġa l-kontenut. Aħna nużaw skala z-index default f'Bootstrap li ġiet iddisinjata biex tgħaqqad sew navigazzjoni, tooltips u popovers, modals, u aktar.
Dawn il-valuri ogħla jibdew minn numru arbitrarju, għoli u speċifiku biżżejjed biex idealment jiġu evitati l-kunflitti. Għandna bżonn sett standard ta 'dawn madwar il-komponenti f'saffi tagħna—tooltips, popovers, navbars, dropdowns, modals — sabiex inkunu raġonevolment konsistenti fl-imgieba. M'hemm l-ebda raġuni li ma stajnax użajna 100
+ jew 500
+.
Aħna ma ninkoraġġixxu l-adattament ta 'dawn il-valuri individwali; jekk tibdel wieħed, x'aktarx ikollok bżonn tibdelhom kollha.
$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;
Biex nittrattaw fruntieri li jikkoinċidu fi ħdan komponenti (eż., buttuni u inputs fi gruppi ta 'input), nużaw z-index
valuri baxxi ta' ċifra waħda ta ' 1
, 2
, u 3
għal stati default, hover, u attivi. Fuq hover/fokus/attiv, inġibu element partikolari fuq quddiem b'valur ogħla z-index
biex juru l-fruntiera tagħhom fuq l-elementi aħwa.