Nā ʻāpana
E aʻo pehea a no ke aha mākou e kūkulu ai i kā mākou ʻāpana āpau me ka pane a me nā papa kumu a me nā papa hoʻololi.
Nā papa kumu
Kūkulu nui ʻia nā ʻāpana o Bootstrap me kahi nomenclature base-modifier. Hoʻohui mākou i nā waiwai kaʻana like i hiki i loko o kahi papa kumu, e like me .btn
, a laila hui pū i nā kaila pākahi no kēlā me kēia ʻano i nā papa hoʻololi, like a i .btn-primary
ʻole .btn-success
.
No ke kūkulu ʻana i kā mākou papa hoʻololi, hoʻohana mākou i nā @each
puka lou Sass e hoʻololi i kahi palapala ʻāina Sass. He mea kōkua nui kēia no ka hana ʻana i nā ʻano like ʻole o kahi ʻāpana e kā mākou $theme-colors
a hana i nā ʻano pane pane no kēlā me kēia breakpoint. Ke hoʻopilikino ʻoe i kēia mau palapala ʻāina Sass a hoʻohui hou, ʻike ʻoe i kāu mau loli i ʻike ʻia i kēia mau puka lou.
E nānā i kā mākou palapala ʻāina Sass a me nā puka lou no ka hoʻopilikino ʻana i kēia mau puka lou a hoʻonui i ke ala hoʻololi hoʻololi kumu o Bootstrap i kāu code ponoʻī.
Nā mea hoʻololi
Hoʻokumu ʻia nā ʻāpana he nui o Bootstrap me kahi papa hoʻololi base-modifier. 'O ia ho'i, aia ka nui o ka hana 'ana i ka papa kumu (e la'a, .btn
) a'o ka ho'ololi 'ana i ka papa ho'ololi (eg, .btn-danger
). Kūkulu ʻia kēia mau papa hoʻololi mai ka $theme-colors
palapala ʻāina e hana maʻamau i ka helu a me ka inoa o kā mākou papa hoʻololi.
Eia nā laʻana ʻelua o ke ʻano o kā mākou hoʻololi ʻana i ka $theme-colors
palapala ʻāina e hana i nā mea hoʻololi i ka .alert
a me .list-group
nā ʻāpana.
// Generate contextual modifier classes for colorizing the alert.
@each $state, $value in $theme-colors {
$alert-background: shift-color($value, $alert-bg-scale);
$alert-border: shift-color($value, $alert-border-scale);
$alert-color: shift-color($value, $alert-color-scale);
@if (contrast-ratio($alert-background, $alert-color) < $min-contrast-ratio) {
$alert-color: mix($value, color-contrast($alert-background), abs($alert-color-scale));
}
.alert-#{$state} {
@include alert-variant($alert-background, $alert-border, $alert-color);
}
}
// List group contextual variants
//
// Add modifier classes to change text and background color on individual items.
// Organizationally, this must come after the `:hover` states.
@each $state, $value in $theme-colors {
$list-group-variant-bg: shift-color($value, $list-group-item-bg-scale);
$list-group-variant-color: shift-color($value, $list-group-item-color-scale);
@if (contrast-ratio($list-group-variant-bg, $list-group-variant-color) < $min-contrast-ratio) {
$list-group-variant-color: mix($value, color-contrast($list-group-variant-bg), abs($list-group-item-color-scale));
}
@include list-group-item-variant($state, $list-group-variant-bg, $list-group-variant-color);
}
Pane
ʻAʻole kaupalena ʻia kēia mau puka lou Sass i nā palapala ʻāina kala. Hiki iā ʻoe ke hana i nā ʻano like ʻole o kāu mau ʻāpana. E noʻonoʻo i kā mākou alignment pane o nā hāʻule iho kahi e hui ai mākou i kahi @each
loop no ka $grid-breakpoints
palapala Sass me kahi nīnau media.
// We deliberately hardcode the `bs-` prefix because we check
// this custom property in JS to determine Popper's positioning
@each $breakpoint in map-keys($grid-breakpoints) {
@include media-breakpoint-up($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
.dropdown-menu#{$infix}-start {
--bs-position: start;
&[data-bs-popper] {
right: auto;
left: 0;
}
}
.dropdown-menu#{$infix}-end {
--bs-position: end;
&[data-bs-popper] {
right: 0;
left: auto;
}
}
}
}
Inā ʻoe e hoʻololi i kāu $grid-breakpoints
, e pili ana kāu mau hoʻololi i nā puka lou e hoʻololi ana ma luna o kēlā palapala ʻāina.
$grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1400px
);
No ka ʻike hou aku a me nā laʻana e pili ana i ka hoʻololi ʻana i kā mākou mau palapala Sass a me nā mea hoʻololi, e ʻoluʻolu e nānā i ka ʻāpana Sass o ka palapala Grid .
Ke hana ʻana iā ʻoe iho
Paipai mākou iā ʻoe e ʻae i kēia mau alakaʻi i ke kūkulu ʻana me Bootstrap e hana i kāu mau ʻāpana ponoʻī. Ua hoʻonui mākou i kēia ala iā mākou iho i nā mea maʻamau i kā mākou palapala a me nā laʻana. Kūkulu ʻia nā ʻāpana e like me kā mākou callout e like me kā mākou mea i hāʻawi ʻia me nā papa kumu a me nā papa hoʻololi.
<div class="callout">...</div>
Ma kāu CSS, loaʻa iā ʻoe kekahi mea e like me kēia ma kahi i hana ʻia ai ka nui o ke ʻano ma o .callout
. A laila, mālama ʻia nā ʻano ʻokoʻa ma waena o kēlā me kēia ʻano ma o ka papa hoʻololi.
// Base class
.callout {}
// Modifier classes
.callout-info {}
.callout-warning {}
.callout-danger {}
No nā callouts, ʻo kēlā ʻano ʻano ʻokoʻa he border-left-color
. Ke hoʻohui ʻoe i kēlā papa kumu me kekahi o kēlā mau papa hoʻololi, loaʻa iā ʻoe kāu ʻohana ʻāpana piha: