Theming Bootstrap
Customize Bootstrap 4 nrog peb cov tshiab Sass variables rau lub ntiaj teb no style nyiam rau yooj yim theming thiab tivthaiv hloov.
Taw qhia
Hauv Bootstrap 3, theming feem ntau tau tsav los ntawm qhov sib txawv ntawm qhov tsis sib xws hauv LESS, kev cai CSS, thiab cov ntsiab lus cais uas peb suav nrog hauv peb dist
cov ntaub ntawv. Nrog rau qee qhov kev siv zog, ib tus tuaj yeem rov tsim kho qhov zoo ntawm Bootstrap 3 yam tsis tau kov cov ntaub ntawv tseem ceeb. Bootstrap 4 muab kev paub, tab sis sib txawv me ntsis.
Tam sim no, theming tau ua tiav los ntawm Sass variables, Sass maps, thiab kev cai CSS. Tsis muaj ntau lub ntsiab lus tshwj xeeb stylesheet; Hloov chaw, koj tuaj yeem ua kom lub ntsiab lus tsim los ntxiv gradients, duab ntxoov ntxoo, thiab ntau dua.
Sass
Siv peb qhov chaw Sass cov ntaub ntawv los ua kom zoo dua ntawm qhov sib txawv, daim duab qhia chaw, mixins, thiab ntau dua thaum sau Sass siv koj tus kheej cov khoom vaj khoom tsev pipeline.
Cov ntaub ntawv qauv
Thaum twg ua tau, zam kev hloov kho Bootstrap cov ntaub ntawv tseem ceeb. Rau Sass, uas txhais tau tias tsim koj tus kheej stylesheet uas imports Bootstrap yog li koj tuaj yeem hloov kho thiab txuas ntxiv mus. Piv txwv tias koj siv tus thawj tswj pob xws li npm, koj yuav muaj cov qauv ntaub ntawv zoo li no:
your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss
Yog tias koj tau rub tawm peb cov ntaub ntawv los ntawm cov ntaub ntawv thiab tsis siv tus thawj tswj pob, koj yuav xav teeb tsa ib yam dab tsi zoo ib yam li cov qauv ntawd, khaws Bootstrap cov ntaub ntawv cais tawm ntawm koj tus kheej.
your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss
Kev xa tawm
Hauv koj custom.scss
, koj yuav import Bootstrap qhov chaw Sass cov ntaub ntawv. Koj muaj ob txoj kev xaiv: suav nrog tag nrho cov Bootstrap, lossis xaiv qhov koj xav tau. Peb txhawb cov tom kawg, txawm tias yuav tsum paub tias muaj qee qhov kev xav tau thiab kev vam khom nyob thoob plaws peb cov khoom. Koj tseem yuav tau suav qee qhov JavaScript rau peb cov plugins.
// Custom.scss
// Option A: Include all of Bootstrap
// Include any default variable overrides here (though functions won't be available)
@import "../node_modules/bootstrap/scss/bootstrap";
// Then add additional custom code here
// Custom.scss
// Option B: Include parts of Bootstrap
// 1. Include functions first (so you can manipulate colors, SVGs, calc, etc)
@import "../node_modules/bootstrap/scss/functions";
// 2. Include any default variable overrides here
// 3. Include remainder of required Bootstrap stylesheets
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// 4. Include any optional Bootstrap components as you like
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid";
Nrog rau qhov kev teeb tsa no, koj tuaj yeem pib hloov kho ib qho ntawm Sass variables thiab maps hauv koj custom.scss
. Koj tuaj yeem pib ntxiv qhov seem ntawm Bootstrap hauv qab // Optional
ntu raws li xav tau. Peb xav kom siv tag nrho cov ntshuam pawg los ntawm peb cov bootstrap.scss
ntaub ntawv raws li koj qhov chaw pib.
Hloov pauv tsis tau
Txhua qhov sib txawv Sass hauv Bootstrap suav nrog tus !default
chij tso cai rau koj hla dhau qhov sib txawv ntawm tus nqi qub hauv koj tus kheej Sass yam tsis tau hloov kho Bootstrap qhov chaws. Luam thiab muab tshuaj txhuam cov hloov pauv raws li xav tau, hloov kho lawv cov txiaj ntsig, thiab tshem tawm tus !default
chij. Yog tias qhov hloov pauv tau raug xa mus, ces nws yuav tsis rov muab dua los ntawm qhov tseem ceeb hauv Bootstrap.
Koj yuav pom cov npe tag nrho ntawm Bootstrap qhov hloov pauv hauv scss/_variables.scss
. Qee qhov kev hloov pauv tau teem rau null
, cov kev hloov pauv no tsis tso tawm cov cuab yeej tshwj tsis yog tias lawv tau dhau los hauv koj qhov kev teeb tsa.
Kev hloov pauv hloov pauv yuav tsum tuaj tom qab peb lub zog, qhov hloov pauv, thiab cov khoom sib xyaw raug xa tawm, tab sis ua ntej qhov seem ntawm kev xa khoom.
Nov yog ib qho piv txwv uas hloov qhov background-color
thiab color
rau <body>
thaum importing thiab compiling Bootstrap ntawm npm:
@import "../node_modules/bootstrap/scss/functions";
// Default variable overrides
$body-bg: #000;
$body-color: #111;
// Required
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional Bootstrap components here
@import "../node_modules/bootstrap/scss/root";
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
// etc
Rov ua dua li qhov tsim nyog rau txhua qhov hloov pauv hauv Bootstrap, suav nrog cov kev xaiv thoob ntiaj teb hauv qab no.
Maps thiab loops
Bootstrap 4 suav nrog ib tug puv tes ntawm Sass maps, tus nqi tseem ceeb uas ua rau nws yooj yim dua los tsim cov tsev neeg ntawm CSS muaj feem xyuam. Peb siv Sass maps rau peb cov xim, daim phiaj tawg, thiab lwm yam. Ib yam li Sass variables, tag nrho Sass maps suav nrog tus !default
chij thiab tuaj yeem hla dhau thiab txuas ntxiv.
Qee qhov ntawm peb daim ntawv qhia Sass tau muab tso rau hauv qhov khoob los ntawm lub neej ntawd. Qhov no yog ua kom yooj yim nthuav dav ntawm daim ntawv qhia Sass, tab sis los ntawm tus nqi ntawm kev tshem tawm cov khoom los ntawm daim ntawv qhia me ntsis nyuaj dua.
Hloov daim ntawv qhia
Txhawm rau hloov cov xim uas twb muaj lawm hauv peb $theme-colors
daim ntawv qhia, ntxiv cov hauv qab no rau koj cov ntaub ntawv Sass kev cai:
$theme-colors: (
"primary": #0074d9,
"danger": #ff4136
);
Ntxiv rau daim ntawv qhia
Txhawm rau ntxiv cov xim tshiab rau $theme-colors
, ntxiv tus yuam sij tshiab thiab tus nqi:
$theme-colors: (
"custom-color": #900
);
Tshem tawm ntawm daim ntawv qhia
Txhawm rau tshem tawm cov xim ntawm $theme-colors
, lossis lwm daim ntawv qhia, siv map-remove
. Nco ntsoov tias koj yuav tsum ntxig nws ntawm peb cov kev xav tau thiab cov kev xaiv:
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
$theme-colors: map-remove($theme-colors, "info", "light", "dark");
// Optional
@import "../node_modules/bootstrap/scss/root";
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
...
Yuav tsum tau cov yuam sij
Bootstrap xav tias muaj qee cov yuam sij tshwj xeeb hauv Sass maps thaum peb siv thiab txuas ntxiv rau peb tus kheej. Raws li koj hloov kho cov duab qhia chaw, koj yuav ntsib teeb meem qhov twg ib qho Sass daim ntawv qhia tus yuam sij raug siv.
Piv txwv li, peb siv cov primary
, success
, thiab cov danger
yuam sij los ntawm $theme-colors
kev sib txuas, nyees khawm, thiab daim ntawv xeev. Hloov qhov tseem ceeb ntawm cov yuam sij no yuav tsum tsis muaj teeb meem, tab sis tshem tawm lawv yuav ua rau Sass compilation teeb meem. Hauv cov xwm txheej no, koj yuav tsum tau hloov kho Sass code uas ua rau siv cov txiaj ntsig ntawd.
Muaj nuj nqi
Bootstrap siv ntau lub luag haujlwm Sass, tab sis tsuas yog ib qho subset muaj feem xyuam rau cov ntsiab lus dav dav. Peb tau suav nrog peb txoj haujlwm kom tau txais txiaj ntsig los ntawm cov duab kos duab:
@function color($key: "blue") {
@return map-get($colors, $key);
}
@function theme-color($key: "primary") {
@return map-get($theme-colors, $key);
}
@function gray($key: "100") {
@return map-get($grays, $key);
}
Cov no tso cai rau koj xaiv ib qho xim los ntawm Sass daim ntawv qhia ntau npaum li cas koj yuav siv cov xim txawv ntawm v3.
.custom-element {
color: gray("100");
background-color: theme-color("dark");
}
Peb kuj tseem muaj lwm txoj haujlwm kom tau txais cov xim tshwj xeeb los ntawm $theme-colors
daim ntawv qhia. Cov qib tsis zoo yuav ua rau xim xim, thaum qib siab dua yuav tsaus.
@function theme-color-level($color-name: "primary", $level: 0) {
$color: theme-color($color-name);
$color-base: if($level > 0, #000, #fff);
$level: abs($level);
@return mix($color-base, $color, $level * $theme-color-interval);
}
Hauv kev xyaum, koj yuav hu rau qhov muaj nuj nqi thiab dhau ntawm ob qhov tsis muaj: lub npe ntawm cov xim los ntawm $theme-colors
(xws li, thawj lossis txaus ntshai) thiab qib lej.
.custom-element {
color: theme-color-level(primary, -10);
}
Cov haujlwm ntxiv tuaj yeem raug ntxiv rau yav tom ntej lossis koj tus kheej Sass kev cai los tsim cov haujlwm qib rau Sass maps ntxiv, lossis txawm tias ib qho kev ua haujlwm yog tias koj xav ua ntau yam lus.
Xim sib txawv
Ib qho ntxiv muaj nuj nqi peb suav nrog hauv Bootstrap yog cov xim sib txawv, color-yiq
. Nws siv YIQ xim qhov chaw kom rov qab tau lub teeb ( #fff
) lossis tsaus nti ( #111
) sib txawv xim raws li cov xim hauv paus. Qhov kev ua haujlwm no tshwj xeeb tshaj yog muaj txiaj ntsig zoo rau mixins lossis loops uas koj tab tom tsim ntau chav kawm.
Piv txwv li, los tsim cov xim swatches los ntawm peb $theme-colors
daim ntawv qhia:
@each $color, $value in $theme-colors {
.swatch-#{$color} {
color: color-yiq($value);
}
}
Nws kuj tseem siv tau rau ib qho kev sib piv xav tau:
.custom-element {
color: color-yiq(#000); // returns `color: #fff`
}
Koj tuaj yeem hais qhia lub hauv paus xim nrog peb daim ntawv qhia xim ua haujlwm:
.custom-element {
color: color-yiq(theme-color("dark")); // returns `color: #fff`
}
Escape SVG
Peb siv cov escape-svg
haujlwm kom khiav tawm <
, >
thiab #
cov cim rau SVG cov duab tom qab. Cov cim no yuav tsum tau khiav tawm kom ua tiav cov duab tom qab hauv IE. Thaum siv cov escape-svg
haujlwm, cov ntaub ntawv URIs yuav tsum tau hais.
Ntxiv thiab rho tawm haujlwm
Peb siv cov haujlwm add
thiab subtract
ua haujlwm los qhwv CSS calc
muaj nuj nqi. Lub hom phiaj tseem ceeb ntawm cov haujlwm no yog kom tsis txhob ua yuam kev thaum tus nqi "unitless" 0
tau dhau mus rau hauv ib qho calc
kev qhia. Cov lus zoo li calc(10px - 0)
yuav rov qab ua qhov yuam kev hauv txhua qhov browsers, txawm tias ua lej raug.
Piv txwv qhov twg calc siv tau:
$border-radius: .25rem;
$border-width: 1px;
.element {
// Output calc(.25rem - 1px) is valid
border-radius: calc($border-radius - $border-width);
}
.element {
// Output the same calc(.25rem - 1px) as above
border-radius: subtract($border-radius, $border-width);
}
Piv txwv qhov twg calc tsis raug:
$border-radius: .25rem;
$border-width: 0;
.element {
// Output calc(.25rem - 0) is invalid
border-radius: calc($border-radius - $border-width);
}
.element {
// Output .25rem
border-radius: subtract($border-radius, $border-width);
}
Sass xaiv
Customize Bootstrap 4 nrog peb cov ntaub ntawv sib txawv ua ke thiab yooj yim toggle thoob ntiaj teb CSS nyiam nrog $enable-*
Sass hloov tshiab. Override ib tug sib txawv tus nqi thiab recompile nrog npm run test
raws li xav tau.
Koj tuaj yeem nrhiav thiab kho qhov hloov pauv no rau cov kev xaiv thoob ntiaj teb tseem ceeb hauv Bootstrap cov scss/_variables.scss
ntaub ntawv.
Hloov pauv | Tus nqi | Kev piav qhia |
---|---|---|
$spacer |
1rem (default), lossis ib qho nqi> 0 |
Qhia meej tus nqi spacer default rau programmatically tsim peb spacer utilities . |
$enable-rounded |
true (default) los yogfalse |
Ua kom cov border-radius qauv uas tau hais ua ntej ntawm ntau yam khoom. |
$enable-shadows |
true los yog false (default) |
Pab kom zoo nkauj zoo box-shadow nkauj ua ntej ntawm ntau yam khoom. Tsis cuam tshuam box-shadow s siv rau lub xeev tsom. |
$enable-gradients |
true los yog false (default) |
Ua kom cov gradients predefined los ntawm background-image cov qauv ntawm ntau yam khoom. |
$enable-transitions |
true (default) los yogfalse |
Enables predefined transition s ntawm ntau yam Cheebtsam. |
$enable-prefers-reduced-motion-media-query |
true (default) los yogfalse |
Tso cai rau prefers-reduced-motion cov lus nug xov xwm , uas txwv tsis pub qee cov animations / kev hloov pauv raws li cov neeg siv browser / kev ua haujlwm nyiam. |
$enable-hover-media-query |
true los yog false (default) |
Deprecated |
$enable-grid-classes |
true (default) los yogfalse |
Ua kom muaj cov chav kawm CSS rau cov kab sib chaws (xws li, .container , .row , .col-md-1 , thiab lwm yam). |
$enable-caret |
true (default) los yogfalse |
Enables pseudo element caret rau .dropdown-toggle . |
$enable-pointer-cursor-for-buttons |
true (default) los yogfalse |
Ntxiv "tes" tus cursor rau cov ntsiab lus uas tsis yog neeg xiam oob qhab. |
$enable-print-styles |
true (default) los yogfalse |
Ua kom cov qauv rau optimizing luam ntawv. |
$enable-responsive-font-sizes |
true los yog false (default) |
Pab kom teb cov font loj . |
$enable-validation-icons |
true (default) los yogfalse |
Ua kom background-image cov cim nyob rau hauv cov ntawv nyeem thiab qee cov ntaub ntawv kev cai rau kev siv tau. |
$enable-deprecation-messages |
true (default) los yogfalse |
Teem kom false zais cov lus ceeb toom thaum siv ib qho ntawm cov khoom siv tsis txaus ntseeg thiab cov haujlwm uas tau npaj yuav raug tshem tawm hauv v5 . |
Xim
Ntau yam ntawm Bootstrap ntau yam khoom siv thiab cov khoom siv tau tsim los ntawm cov xim sib txawv hauv Sass daim ntawv qhia. Daim ntawv qhia no tuaj yeem hla dhau hauv Sass kom sai sai ua kom muaj ntau txoj cai.
Txhua xim
Txhua xim muaj nyob rau hauv Bootstrap 4, muaj raws li Sass variables thiab Sass daim ntawv qhia hauv scss/_variables.scss
cov ntaub ntawv. Qhov no yuav nthuav dav ntxiv rau hauv cov kev tso tawm me me ntxiv ntxiv rau qhov ntxoov ntxoo ntxiv, zoo li cov xim grey palette peb twb suav nrog.
Nov yog qhov koj tuaj yeem siv cov no hauv koj Sass:
// With variable
.alpha { color: $purple; }
// From the Sass map with our `color()` function
.beta { color: color("purple"); }
Cov chav kawm siv xim xim kuj muaj rau kev teeb tsa color
thiab background-color
.
Xim xim
Peb siv subset ntawm tag nrho cov xim los tsim ib tug me me xim palette rau tsim xim schemes, kuj muaj raws li Sass variables thiab ib daim ntawv qhia Sass nyob rau hauv Bootstrap cov scss/_variables.scss
ntaub ntawv.
Grey
Ib qho kev nthuav dav ntawm grey variables thiab Sass daim ntawv qhia nyob rau hauv scss/_variables.scss
kom zoo ib yam ntxoov grey thoob plaws koj qhov project. Nco ntsoov tias cov no yog "txias greys", uas nyiam mus rau lub suab xiav maj mam, tsis yog nruab nrab greys.
Tsis pub dhau scss/_variables.scss
, koj yuav pom Bootstrap cov xim sib txawv thiab Sass daim ntawv qhia. Nov yog ib qho piv txwv ntawm $colors
Sass map:
$colors: (
"blue": $blue,
"indigo": $indigo,
"purple": $purple,
"pink": $pink,
"red": $red,
"orange": $orange,
"yellow": $yellow,
"green": $green,
"teal": $teal,
"cyan": $cyan,
"white": $white,
"gray": $gray-600,
"gray-dark": $gray-800
) !default;
Ntxiv, tshem tawm, lossis hloov kho qhov tseem ceeb hauv daim duab qhia kev hloov kho lawv siv li cas hauv ntau lwm yam. Hmoov tsis zoo nyob rau lub sijhawm no, tsis yog txhua yam khoom siv siv daim ntawv qhia Sass no. Cov kev hloov tshiab yav tom ntej yuav siv zog los txhim kho qhov no. Txog thaum ntawd, npaj rau kev siv cov ${color}
hloov pauv thiab daim ntawv qhia Sass no.
Cheebtsam
Ntau yam ntawm Bootstrap cov khoom thiab cov khoom siv hluav taws xob tau tsim nrog cov @each
voj voog uas rov ua dua ib daim ntawv qhia Sass. Qhov no yog qhov tshwj xeeb tshaj yog pab rau kev tsim cov kev sib txawv ntawm cov khoom siv los ntawm peb $theme-colors
thiab tsim cov kev hloov pauv rau txhua qhov kev tawg. Thaum koj kho cov Sass maps thiab rov ua dua, koj yuav pom koj cov kev hloov pauv tshwm sim hauv cov voj voog no.
Hloov kho
Ntau yam ntawm Bootstrap cov khoom yog tsim nrog lub hauv paus-modifier class mus kom ze. Qhov no txhais tau hais tias feem ntau ntawm cov styling muaj nyob rau hauv cov chav kawm (piv txwv li, .btn
) thaum style variations raug txwv rau cov chav kawm hloov kho (xws li, .btn-danger
). Cov chav kawm hloov kho no yog tsim los ntawm $theme-colors
daim ntawv qhia kom kho tus lej thiab lub npe ntawm peb cov chav kawm hloov kho.
Nov yog ob qho piv txwv ntawm yuav ua li cas peb voj hla $theme-colors
daim ntawv qhia los tsim cov kev hloov pauv rau cov .alert
khoom siv thiab tag nrho peb .bg-*
cov khoom siv tom qab.
// Generate alert modifier classes
@each $color, $value in $theme-colors {
.alert-#{$color} {
@include alert-variant(theme-color-level($color, -10), theme-color-level($color, -9), theme-color-level($color, 6));
}
}
// Generate `.bg-*` color utilities
@each $color, $value in $theme-colors {
@include bg-variant('.bg-#{$color}', $value);
}
Teb
Cov Sass loops no tsis txwv rau cov duab kos duab, ib yam nkaus. Koj tseem tuaj yeem tsim cov kev hloov pauv ntawm koj cov khoom lossis cov khoom siv. Ua piv txwv peb cov lus teb cov khoom siv sib txuas lus uas peb sib xyaw ua ke @each
rau $grid-breakpoints
Sass daim ntawv qhia nrog cov lus nug hauv xov xwm suav nrog.
@each $breakpoint in map-keys($grid-breakpoints) {
@include media-breakpoint-up($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
.text#{$infix}-left { text-align: left !important; }
.text#{$infix}-right { text-align: right !important; }
.text#{$infix}-center { text-align: center !important; }
}
}
Yog tias koj xav tau hloov kho koj $grid-breakpoints
, koj cov kev hloov pauv yuav siv rau txhua lub voj voog rov ua dua daim ntawv qhia ntawd.
CSS variables
Bootstrap 4 suav nrog ib ncig ntawm ob lub kaum os CSS kev cai cov khoom (kuj hloov pauv) hauv nws cov CSS suav. Cov no muab kev nkag tau yooj yim rau cov txiaj ntsig zoo ib yam li peb cov ntsiab lus xim, cov ntsiab lus tawg, thiab cov font loj loj thaum ua haujlwm hauv koj tus browser tus neeg soj ntsuam, code sandbox, lossis kev tsim qauv.
Muaj variables
Nov yog cov kev hloov pauv uas peb suav nrog (nco ntsoov tias qhov :root
yuav tsum tau ua). Lawv nyob hauv peb cov _root.scss
ntaub ntawv.
:root {
--blue: #007bff;
--indigo: #6610f2;
--purple: #6f42c1;
--pink: #e83e8c;
--red: #dc3545;
--orange: #fd7e14;
--yellow: #ffc107;
--green: #28a745;
--teal: #20c997;
--cyan: #17a2b8;
--white: #fff;
--gray: #6c757d;
--gray-dark: #343a40;
--primary: #007bff;
--secondary: #6c757d;
--success: #28a745;
--info: #17a2b8;
--warning: #ffc107;
--danger: #dc3545;
--light: #f8f9fa;
--dark: #343a40;
--breakpoint-xs: 0;
--breakpoint-sm: 576px;
--breakpoint-md: 768px;
--breakpoint-lg: 992px;
--breakpoint-xl: 1200px;
--font-family-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
Piv txwv
CSS variables muaj qhov hloov pauv zoo sib xws rau Sass's variables, tab sis tsis tas yuav tsum tau muab tso ua ke ua ntej muab rau browser. Piv txwv li, ntawm no peb tab tom rov pib dua peb nplooj ntawv font thiab txuas cov qauv nrog CSS sib txawv.
body {
font: 1rem/1.5 var(--font-family-sans-serif);
}
a {
color: var(--blue);
}
Breakpoint variables
Thaum peb xub suav nrog cov ntsiab lus sib cais hauv peb cov CSS hloov pauv (xws li, --breakpoint-md
), cov no tsis txaus siab hauv cov lus nug xov xwm , tab sis lawv tseem tuaj yeem siv tau hauv cov cai hauv cov lus nug hauv xov xwm. Cov kev hloov pauv no tseem nyob hauv CSS suav nrog rau kev rov qab sib raug zoo muab lawv tuaj yeem siv los ntawm JavaScript. Kawm ntxiv hauv spec .
Nov yog ib qho piv txwv ntawm qhov tsis txaus siab:
@media (min-width: var(--breakpoint-sm)) {
...
}
Thiab ntawm no yog ib qho piv txwv ntawm qhov kev txhawb nqa:
@media (min-width: 768px) {
.custom-element {
color: var(--primary);
}
}