Nā hoʻololi CSS
E hoʻohana i nā waiwai maʻamau o Bootstrap CSS no ka hoʻolālā a me ka hoʻomohala wikiwiki.
Loaʻa iā Bootstrap nā waiwai maʻamau CSS (nā mea hoʻololi) i kāna CSS i hōʻuluʻulu ʻia no ka hana maʻamau maoli me ka ʻole o ka pono e hoʻohui hou iā Sass. Hāʻawi kēia mau mea i ke ala maʻalahi i nā waiwai i hoʻohana mau ʻia e like me kā mākou kala kumumanaʻo, nā wahi haʻihaʻi, a me nā hoʻopaʻa kikokikona mua i ka wā e hana ai i kāu mākaʻikaʻi o kāu polokalamu kele pūnaewele, kahi pahu pahu code, a i ʻole prototyping maʻamau.
Hoʻopili mua ʻia kā mākou mau waiwai maʻamau mebs-
ka pale ʻana i nā paio me ka CSS ʻaoʻao ʻekolu.
Nā hoʻololi kumu
Eia nā mea hoʻololi a mākou e hoʻokomo ai (e hoʻomaopopo :root
he koi ʻia) hiki ke kiʻi ʻia ma nā wahi āpau i hoʻouka ʻia ai ka CSS o Bootstrap. Aia lākou i loko o kā mākou _root.scss
faila a hoʻokomo ʻia i kā mākou faila dist i hui ʻia.
:root {
--bs-blue: #0d6efd;
--bs-indigo: #6610f2;
--bs-purple: #6f42c1;
--bs-pink: #d63384;
--bs-red: #dc3545;
--bs-orange: #fd7e14;
--bs-yellow: #ffc107;
--bs-green: #198754;
--bs-teal: #20c997;
--bs-cyan: #0dcaf0;
--bs-black: #000;
--bs-white: #fff;
--bs-gray: #6c757d;
--bs-gray-dark: #343a40;
--bs-gray-100: #f8f9fa;
--bs-gray-200: #e9ecef;
--bs-gray-300: #dee2e6;
--bs-gray-400: #ced4da;
--bs-gray-500: #adb5bd;
--bs-gray-600: #6c757d;
--bs-gray-700: #495057;
--bs-gray-800: #343a40;
--bs-gray-900: #212529;
--bs-primary: #0d6efd;
--bs-secondary: #6c757d;
--bs-success: #198754;
--bs-info: #0dcaf0;
--bs-warning: #ffc107;
--bs-danger: #dc3545;
--bs-light: #f8f9fa;
--bs-dark: #212529;
--bs-primary-rgb: 13, 110, 253;
--bs-secondary-rgb: 108, 117, 125;
--bs-success-rgb: 25, 135, 84;
--bs-info-rgb: 13, 202, 240;
--bs-warning-rgb: 255, 193, 7;
--bs-danger-rgb: 220, 53, 69;
--bs-light-rgb: 248, 249, 250;
--bs-dark-rgb: 33, 37, 41;
--bs-white-rgb: 255, 255, 255;
--bs-black-rgb: 0, 0, 0;
--bs-body-color-rgb: 33, 37, 41;
--bs-body-bg-rgb: 255, 255, 255;
--bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
--bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
--bs-body-font-family: var(--bs-font-sans-serif);
--bs-body-font-size: 1rem;
--bs-body-font-weight: 400;
--bs-body-line-height: 1.5;
--bs-body-color: #212529;
--bs-body-bg: #fff;
--bs-border-width: 1px;
--bs-border-style: solid;
--bs-border-color: #dee2e6;
--bs-border-color-translucent: rgba(0, 0, 0, 0.175);
--bs-border-radius: 0.375rem;
--bs-border-radius-sm: 0.25rem;
--bs-border-radius-lg: 0.5rem;
--bs-border-radius-xl: 1rem;
--bs-border-radius-2xl: 2rem;
--bs-border-radius-pill: 50rem;
--bs-link-color: #0d6efd;
--bs-link-hover-color: #0a58ca;
--bs-code-color: #d63384;
--bs-highlight-bg: #fff3cd;
}
Nā mea hoʻololi
Ke hoʻohana nui nei ʻo Bootstrap 5 i nā waiwai maʻamau e like me nā loli kūloko no nā ʻāpana like ʻole. Ma kēia ala mākou e hōʻemi ai i kā mākou CSS i hōʻuluʻulu ʻia, e hōʻoiaʻiʻo ʻaʻole i hoʻoili ʻia nā ʻano i nā wahi e like me nā papa pūnana, a e ʻae i ka hoʻomaha ʻana a me ka hoʻonui ʻana i nā ʻāpana Bootstrap ma hope o ka hui ʻana o Sass.
E nānā i kā mākou palapala papaʻaina no ka ʻike i ke ʻano o kā mākou hoʻohana ʻana i nā ʻano CSS . Hoʻohana pū kā mākou navbars i nā mea hoʻololi CSS e like me v5.2.0. Ke hoʻohana nei mākou i nā mea hoʻololi CSS ma ko mākou mau mākia—no ka mea nui no nā awāwa i ka māka CSS koho hou— me ka hoʻohana hou ʻana i nā mea e hiki mai ana i ka wā e hiki mai ana.
I nā manawa a pau e hiki ai, e hāʻawi mākou i nā mea hoʻololi CSS ma ka pae ʻāpana kumu (e laʻa, .navbar
no ka navbar a me kāna mau ʻāpana). Hoʻemi kēia i ka koho ʻana i kahi a pehea e hana ai, a hiki i nā hoʻololi maʻalahi e kā mākou hui i nā mea hou e hiki mai ana.
Prefix
Hoʻohana ka hapa nui o nā mea hoʻololi CSS i kahi prefix e pale aku i ka hui ʻana me kāu codebase ponoʻī. Hoʻohui ʻia kēia prefix i ka --
mea i koi ʻia ma kēlā me kēia hoʻololi CSS.
Hoʻopilikino i ka prefix ma o ka $prefix
hoʻololi Sass. Ma ka paʻamau, ua hoʻonohonoho ʻia i bs-
(e nānā i ka ʻaoʻao hope).
Nā laʻana
Hāʻawi nā mea hoʻololi CSS i ka maʻalahi like me nā ʻano like ʻole o Sass, akā me ka ʻole o ka pono o ka hoʻohui ʻana ma mua o ka lawelawe ʻana i ka polokalamu kele pūnaewele. Eia kekahi laʻana, eia mākou e hoʻonohonoho hou ana i kā mākou ʻaoʻao font a me nā ʻano loulou me nā ʻano CSS.
body {
font: 1rem/1.5 var(--bs-font-sans-serif);
}
a {
color: var(--bs-blue);
}
Nā wahi haʻihaʻi
ʻOiai mākou e hoʻokomo i kā mākou mau wahi haʻihaʻi ma ke ʻano he mau hoʻololi CSS (koe wale nō xs
), e makaʻala ʻaʻole hana nā mea hoʻololi CSS i nā nīnau media . ʻO kēia ma ka hoʻolālā ʻana i ka kikoʻī CSS no nā mea hoʻololi, akā hiki ke loli i nā makahiki e hiki mai ana me ke kākoʻo ʻana i env()
nā loli. E nānā i kēia pane Stack Overflow no kekahi mau loulou kōkua. I kēia manawa, hiki iā ʻoe ke hoʻohana i kēia mau hoʻololi i nā kūlana CSS ʻē aʻe, a me kāu JavaScript.