Source

Visió general

Components i opcions per dissenyar el vostre projecte Bootstrap, inclosos contenidors d'embolcall, un potent sistema de quadrícula, un objecte multimèdia flexible i classes d'utilitat sensibles.

Contenidors

Els contenidors són l'element de disseny més bàsic a Bootstrap i són necessaris quan s'utilitza el nostre sistema de graella predeterminat . Trieu entre un contenidor sensible i d'amplada fixa (és a dir, els seus max-widthcanvis a cada punt d'interrupció) o d'amplada fluida (és a dir, és 100%ample tot el temps).

Tot i que els contenidors es poden imbricar, la majoria de dissenys no requereixen un contenidor imbricat.

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

Utilitzeu .container-fluid-lo per a un contenidor d'amplada completa, que abasti tota l'amplada de la finestra gràfica.

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

Punts d'interrupció sensibles

Com que Bootstrap està desenvolupat per ser mòbil primer, fem servir un bon grapat de consultes multimèdia per crear punts d'interrupció raonables per als nostres dissenys i interfícies. Aquests punts d'interrupció es basen principalment en amplades mínimes de la finestra gràfica i ens permeten augmentar l'escala dels elements a mesura que canvia la finestra gràfica.

Bootstrap utilitza principalment els següents intervals de consulta de mitjans (o punts d'interrupció) als nostres fitxers Sass d'origen per al nostre disseny, sistema de quadrícula i components.

// Extra small devices (portrait phones, less than 576px)
// No media query 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) { ... }

Com que escrivim el nostre CSS d'origen a Sass, totes les nostres consultes multimèdia estan disponibles mitjançant mixins de Sass:

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

// Example usage:
@include media-breakpoint-up(sm) {
  .some-class {
    display: block;
  }
}

We occasionally use media queries that go in the other direction (the given screen size or smaller):

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

Note that since browsers do not currently support range context queries, we work around the limitations of min- and max- prefixes and viewports with fractional widths (which can occur under certain conditions on high-dpi devices, for instance) by using values with higher precision for these comparisons.

Once again, these media queries are also available via Sass mixins:

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

There are also media queries and mixins for targeting a single segment of screen sizes using the minimum and maximum 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) { ... }

These media queries are also available via 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) { ... }

Similarly, media queries may span multiple breakpoint widths:

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

The Sass mixin for targeting the same screen size range would be:

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

Z-index

Several Bootstrap components utilize z-index, the CSS property that helps control layout by providing a third axis to arrange content. We utilize a default z-index scale in Bootstrap that’s been designed to properly layer navigation, tooltips and popovers, modals, and more.

These higher values start at an arbitrary number, high and specific enough to ideally avoid conflicts. We need a standard set of these across our layered components—tooltips, popovers, navbars, dropdowns, modals—so we can be reasonably consistent in the behaviors. There’s no reason we couldn’t have used 100+ or 500+.

We don’t encourage customization of these individual values; should you change one, you likely need to change them all.

$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;

Per gestionar les vores superposades dins dels components (p. ex., botons i entrades en grups d'entrada), utilitzem z-indexvalors d' un dígit baix de 1, 2, i 3per als estats predeterminats, desplaçament i actiu. En passar el cursor/enfocar/actiu, portem un element particular al primer pla amb un z-indexvalor més alt per mostrar la seva vora sobre els elements germans.