Reboot no bio
Reboot, element-specific CSS nsakraeɛ a wɔaboaboa ano wɔ fael baako mu, kickstart Bootstrap ma ɛde mfitiaseɛ a ɛyɛ fɛ, ɛkɔ so daa, na ɛnyɛ den a wobɛsi so.
Kwan
Reboot gyina Normalize so, ɛma HTML elements pii a ɛwɔ adwene bi a ɛwɔ adwene a wɔde element selectors nkutoo di dwuma. Wɔde adesua ahorow nkutoo na ɛyɛ styling foforo. Sɛ nhwɛso no, yɛsan bɔ <table>
style ahorow bi ma baseline a ɛyɛ mmerɛw na akyiri yi yɛde .table
, .table-bordered
, ne nea ɛkeka ho ma.
Yɛn akwankyerɛ ne ntease ahorow a enti ɛsɛ sɛ wopaw nea ɛsɛ sɛ wobɔ so wɔ Reboot mu ni:
- Yɛ browser default values binom foforo na fa
rem
s di dwuma sen sɛ wode s bedi dwumaem
ama scalable component spacing. - Kwati sɛ
margin-top
. Nneɛma a ɛwɔ nkyɛnkyɛn a ɛda hɔ gyina hɔ no betumi abubu, na ɛde nneɛma a wɔnhwɛ kwan aba. Nanso nea ɛho hia kɛse no, akwankyerɛ biako a wɔde mamargin
ne adwene mu nhwɛso a ɛyɛ mmerɛw. - Sɛnea ɛbɛyɛ a ɛbɛyɛ mmerɛw sɛ wobɛma scaling wɔ device sizes nyinaa mu no, ɛsɛ sɛ block elements de s di dwuma
rem
mamargin
s. - Ma mpaemuka a
font
ɛfa -a ɛfa agyapade ho no nyɛ nea ɛba fam koraa, fa di dwumainherit
bere biara a ɛbɛyɛ yiye.
CSS nsakrae ahorow
Wɔde aka ho wɔ v5.2.0 muYɛnam v5.1.1 so no, yɛde yɛn @import
s a yɛhwehwɛ no yɛɛ gyinapɛn wɔ yɛn CSS bundles nyinaa mu (a bootstrap.css
, bootstrap-reboot.css
, ne bootstrap-grid.css
) ka ho de ka ho _root.scss
. Wei de :root
level CSS variables ka bundles nyinaa ho, a emu dodoɔ a wɔde di dwuma wɔ saa bundle no mu mfa ho. Awiei koraa no Bootstrap 5 bɛkɔ so ahu CSS nsakrae pii a wɔde aka ho bere kɔ so, sɛnea ɛbɛyɛ a ɛbɛma bere ankasa mu nsakrae pii a ɛho nhia sɛ wɔsan boaboa Sass ano bere nyinaa. Yɛn kwan ne sɛ yɛbɛfa yɛn source Sass variables no na yɛadan no ayɛ no CSS variables. Saa kwan no so no, sɛ woamfa CSS variables anni dwuma mpo a, woda so ara wɔ Sass tumi nyinaa. Eyi da so ara rekɔ so na ebegye bere na wɔde adi dwuma koraa.
Sɛ nhwɛso no, susuw :root
CSS nsakrae ahorow yi ho ma <body>
style ahorow a wɔtaa de di dwuma:
@if $font-size-root != null {
--#{$prefix}root-font-size: #{$font-size-root};
}
--#{$prefix}body-font-family: #{$font-family-base};
@include rfs($font-size-base, --#{$prefix}body-font-size);
--#{$prefix}body-font-weight: #{$font-weight-base};
--#{$prefix}body-line-height: #{$line-height-base};
--#{$prefix}body-color: #{$body-color};
@if $body-text-align != null {
--#{$prefix}body-text-align: #{$body-text-align};
}
--#{$prefix}body-bg: #{$body-bg};
Wɔ adeyɛ mu no, afei wɔde saa variables no di dwuma wɔ Reboot mu te sɛ saa:
body {
margin: 0; // 1
font-family: var(--#{$prefix}body-font-family);
@include font-size(var(--#{$prefix}body-font-size));
font-weight: var(--#{$prefix}body-font-weight);
line-height: var(--#{$prefix}body-line-height);
color: var(--#{$prefix}body-color);
text-align: var(--#{$prefix}body-text-align);
background-color: var(--#{$prefix}body-bg); // 2
-webkit-text-size-adjust: 100%; // 3
-webkit-tap-highlight-color: rgba($black, 0); // 4
}
Nea ɛma wo kwan ma woyɛ bere ankasa mu nsakrae sɛnea wopɛ biara:
<body style="--bs-body-color: #333;">
<!-- ... -->
</body>
Kratafa no yɛ nea wɔahyɛ da ayɛ
Wɔayɛ <html>
ne <body>
elements no foforo de ama kratafa no nyinaa defaults a eye. Nea ɛkɔ akyiri yi:
- Wɔde
box-sizing
wiase nyinaa asi element biara so—a*::before
ne , ka ho*::after
, kosiborder-box
. Wei hwɛ sɛ element no trɛw a wɔabɔ ho dawuru no rentra da esiane padding anaa border nti.- Wɔmmɔ nnyinaso
font-size
biara ho dawuru wɔ<html>
, nanso16px
wɔfa no sɛ (browsa no default).font-size: 1rem
wɔde di dwuma wɔ the<body>
for easy responsive type-scaling via media queries bere a wɔkyerɛ obu ma nea ɔde di dwuma no apɛde na ɛhwɛ hu sɛ wɔfa ɔkwan a ɛyɛ mmerɛw so. Wobetumi abɔ browser default yi so denam nsakrae a wobɛsakra no$font-size-root
so.
- Wɔmmɔ nnyinaso
- The
<body>
nso de wiase nyinaafont-family
,font-weight
,line-height
, necolor
. Eyi fi awo mu akyiri yi denam form elements binom so de siw font a enhyia ano. - Sɛnea ɛbɛyɛ a ahobammɔ bɛba no, the
<body>
has abackground-color
declared , defaulting to#fff
.
Native font a wɔde ahyɛ mu
Bootstrap de “native font stack” anaa “system font stack” di dwuma ma nsɛm a wɔkyerɛ ase yiye wɔ mfiri ne OS biara so. Wɔayɛ nhyehyɛe font ahorow yi titiriw a nnɛyi mfiri ahorow no wɔ wɔn adwenem, a wɔatu mpɔn wɔ nkyerɛase ahorow so, font ahorow a ɛsakra, ne nea ɛkeka ho. Kenkan native font stacks ho nsɛm pii wɔ Smashing Magazine asɛm yi mu .
$font-family-sans-serif:
// Cross-platform generic font family (default user interface font)
system-ui,
// Safari for macOS and iOS (San Francisco)
-apple-system,
// Windows
"Segoe UI",
// Android
Roboto,
// older macOS and iOS
"Helvetica Neue"
// Linux
"Noto Sans",
"Liberation Sans",
// Basic web fallback
Arial,
// Sans serif fallback
sans-serif,
// Emoji fonts
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default;
Hyɛ no nsow sɛ esiane sɛ font stack no de emoji fonts ka ho nti, wɔbɛkyerɛ agyiraehyɛde/dingbat Unicode nkyerɛwde a wɔtaa de di dwuma no pii ase sɛ mfonini ahorow a ɛwɔ kɔla ahorow pii. Wɔn hwɛbea bɛsono, a egyina ɔkwan a wɔfa so de di dwuma wɔ browser/platform no native emoji font no so, na CSS color
kwan biara rennya wɔn so nkɛntɛnso.
Eyi font-family
yɛ nea wɔde di dwuma wɔ <body>
ne automatically inherited wiase nyinaa wɔ Bootstrap nyinaa mu. Sɛ wopɛ sɛ wosakra global font-family
, update $font-family-base
na san boaboa Bootstrap ano.
Nsɛmti ne nkyekyɛm ahorow
Asɛmti no mu nneɛma nyinaa—sɛ nhwɛso no, <h1>
—na <p>
wɔsan de si hɔ sɛnea ɛbɛyɛ a wobeyi wɔn margin-top
afi hɔ. Wɔde nsɛmti ahorow margin-bottom: .5rem
aka ho ne nkyekyem margin-bottom: 1rem
ahorow a ɛbɛma ntam kwan ayɛ mmerɛw.
Asɛmti | Nhwɛsoɔ |
---|---|
<h1></h1> |
h1. Bootstrap asɛmti no |
<h2></h2> |
h2. Bootstrap asɛmti no |
<h3></h3> |
h3. Bootstrap asɛmti no |
<h4></h4> |
h4. Bootstrap asɛmti no |
<h5></h5> |
h5. Bootstrap asɛmti no |
<h6></h6> |
h6. Bootstrap asɛmti no |
Mmara a ɛwɔ sorosoro
Wɔama <hr>
element no ayɛ mmerɛw. Te sɛ browser defaults no, <hr>
s yɛ styled via border-top
, wɔ default opacity: .25
, na automatically inherit wɔn border-color
via color
, a bere color
a set via ɔwofo no ka ho. Wobetumi de text, border, ne opacity utilities ayɛ nsakrae wɔ mu.
<hr>
<div class="text-success">
<hr>
</div>
<hr class="border border-danger border-2 opacity-50">
<hr class="border border-primary border-3 opacity-75">
Nsɛm a wɔahyehyɛ
Lists nyinaa— <ul>
, <ol>
, ne <dl>
—wɔ wɔn a margin-top
wɔayi afi hɔ ne a margin-bottom: 1rem
. Nested list ahorow no nni margin-bottom
. Yɛsan nso reset padding-left
on <ul>
ne <ol>
elements no.
- Wɔayi wɔn atifi margin no afi hɔ a wɔahyehyɛ no nyinaa
- Na wɔn ase fã no yɛɛ nea ɛfata
- Nested lists nni ase fã biara
- Saa kwan yi so no wonya anim a ɛyɛ pɛpɛɛpɛ kɛse
- Titiriw bere a nneɛma pii a wɔahyehyɛ di akyi no
- Wɔasan asiesie benkum so padding no nso
- Nsɛm a wɔahyehyɛ a wɔahyehyɛ ni
- Ne nneɛma kakraa bi a wɔahyehyɛ
- Ɛwɔ ne nyinaa hwɛbea koro no ara
- Sɛnea edi kan a wɔanhyehyɛ no din no
Sɛnea ɛbɛyɛ a wobɛhyehyɛ no mmerɛw, nhyehyɛe a emu da hɔ, ne ntam kwan a eye no, nkyerɛkyerɛmu list ahorow no ayɛ margin
s foforo. <dd>
s reset margin-left
to 0
na fa ka ho margin-bottom: .5rem
. <dt>
s no yɛ nkyerɛwde tuntum .
- Nkyerɛkyerɛmu a wɔahyehyɛ
- Nkyerɛkyerɛmu a wɔahyehyɛ no yɛ pɛpɛɛpɛ ma nsɛmfua nkyerɛase.
- Asɛmfua
- Nkyerɛase a wɔde ma asɛmfua no.
- Nkyerɛase a ɛto so abien ma asɛmfua koro no ara.
- Asɛmfua foforo
- Nkyerɛase a wɔde ma wɔ asɛmfua foforo yi ho.
Inline koodu a ɛwɔ mu
Fa inline snippets a ɛwɔ code no mu no kyekyere <code>
. Hwɛ hu sɛ wubeguan afi HTML anim brackets no mu.
<section>
ɛsɛ sɛ wɔkyekyere no sɛ inline.
For example, <code><section></code> should be wrapped as inline.
Kood a wɔde siw ano
Fa <pre>
s di dwuma ma koodu nkyerɛwde ahorow pii. Saa bere yi nso, hwɛ hu sɛ wubeguan afi anim brackets biara a ɛwɔ code no mu no mu na ama woatumi akyerɛ ase yiye. Wɔsan <pre>
de element no si hɔ de yi ne margin-top
na wɔde rem
units di dwuma ma ne margin-bottom
.
<p>Sample text here...</p>
<p>And another line of sample text here...</p>
<pre><code><p>Sample text here...</p>
<p>And another line of sample text here...</p>
</code></pre>
Nneɛma a Ɛsakra
Sɛ wopɛ sɛ wokyerɛ variables a, fa <var>
tag no di dwuma.
<var>y</var> = <var>m</var><var>x</var> + <var>b</var>
Ɔdefo no nsɛm a wɔde hyɛ mu
Fa no <kbd>
kyerɛ input a wɔtaa fa keyboard so hyɛ mu.
Sɛ wopɛ sɛ wosakra nhyehyɛe ahorow no a, mia so ctrl + ,
To switch directories, type <kbd>cd</kbd> followed by the name of the directory.<br>
To edit settings, press <kbd><kbd>ctrl</kbd> + <kbd>,</kbd></kbd>
Nhwɛsode a efi mu ba
Sɛ wopɛ sɛ wokyerɛ nhwɛsode a efi dwumadi bi mu a, fa <samp>
tag no di dwuma.
<samp>This text is meant to be treated as sample output from a computer program.</samp>
Nnwinnade ahorow
Wɔayɛ pon ahorow no ho nhyehyɛe kakra ma ɛne style <caption>
s, collapse borders, na wɔhwɛ hu sɛ ɛkɔ so daa wɔ ne text-align
nyinaa mu. Nsakrae foforo a ɛfa borders, padding, ne nea ɛkeka ho no ka .table
adesuakuw no ho .
Table asɛmti | Table asɛmti | Table asɛmti | Table asɛmti |
---|---|---|---|
Table cell | Table cell | Table cell | Table cell |
Table cell | Table cell | Table cell | Table cell |
Table cell | Table cell | Table cell | Table cell |
<table>
<caption>
This is an example table, and this is its caption to describe the contents.
</caption>
<thead>
<tr>
<th>Table heading</th>
<th>Table heading</th>
<th>Table heading</th>
<th>Table heading</th>
</tr>
</thead>
<tbody>
<tr>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
</tbody>
</table>
Nkyerɛwee ahorow
Wɔasan ahyɛ form elements ahorow ase ama base styles a ɛyɛ mmerɛw. Nsakrae a ɛda nsow sen biara no bi ni:
<fieldset>
s nni borders, padding, anaa margin enti wobetumi de adi dwuma mmerɛw sɛ wrappers ama ankorankoro inputs anaa inputs akuw.<legend>
s, te sɛ fieldsets, nso wɔasan ayɛ no foforo sɛnea ɛbɛyɛ a wɔbɛda no adi sɛ asɛmti a ɛyɛ ahorow.<label>
s no wɔde asi hɔ sɛdisplay: inline-block
wɔbɛma kwanmargin
ma wɔde adi dwuma.<input>
s,<select>
s,<textarea>
s, ne<button>
s no, Normalize na ɛdi ho dwuma dodoɔ no ara, nanso Reboot yi wɔnmargin
ne setline-height: inherit
, nso.<textarea>
s no yɛ nsakrae ma ɛyɛ nea wotumi sesa ne kɛse vertically nkutoo sɛnea horizontal resizing taa “bubu” kratafa nhyehyɛe no.<button>
s ne<input>
button elements no wɔcursor: pointer
bere a:not(:disabled)
.
Wɔada nsakrae ahorow yi, ne nea ɛkeka ho adi wɔ ase ha.
Date & kɔla a wɔde hyɛ mu mmoa
Ma ɛntena w’adwenem sɛ date inputs no ntumi nhyɛ browser ahorow nyinaa mu koraa, a ɛne Safari.
Nsɛnkyerɛnne a ɛwɔ bɔton ahorow so
Reboot no de nkɔsoɔ bi ka ho ma role="button"
sɛ wobɛsesa default cursor no akɔ pointer
. Fa saa su yi ka element ahorow ho na aboa ma akyerɛ sɛ element ahorow no yɛ nkitahodi. Saa dwumadie yi nhia mma <button>
elements, a wonya wɔn ankasa cursor
nsakraeɛ.
<span role="button" tabindex="0">Non-button element button</span>
Misc nneɛma ahorow
Adrɛse
Wɔayɛ <address>
element no foforo de asan ahyɛ browser no default no font-style
afi italic
kɔ normal
. line-height
no nso mprempren anya agyapade, na margin-bottom: 1rem
wɔde aka ho. <address>
s yɛ nea wɔde bɛma nana a ɔbɛn no paa (anaasɛ adwuma mũ no nyinaa) nkitahodi ho nsɛm. Kora formatting so denam nkyerɛwde a wode bɛhyɛ awiei no so <br>
.
Nsɛm a wɔde siw ano
Default margin
a ɛwɔ blockquotes so ne 1em 40px
, enti yɛsan de saa to 0 0 1rem
hɔ ma biribi a ɛne nneɛma afoforo hyia kɛse.
Asɛm a wɔafa aka a wonim no yiye, a ɛwɔ blockquote element bi mu.
Obi a wagye din wɔ Source Title mu
Nneɛma a ɛwɔ inline mu
Element <abbr>
no nya mfitiase styling ma ɛda nsow wɔ nkyekyɛm nsɛm mu.
Tɔfabɔ
Default cursor
wɔ summary so ne text
, enti yɛsan de saa to pointer
no de kyerɛ sɛ wobetumi ne element no adi nkitaho denam klik a wobɛbɔ so.
Nsɛm bi a ɛkɔ akyiri
More info fa nsɛm no ho.
Nsɛm pii mpo
Nsɛm pii mpo a ɛfa nsɛm no ho ni.
HTML5 [hidden]
su a ɛwɔ hɔ
HTML5 de wiase nyinaa su foforo a wɔato din[hidden]
, a wɔayɛ no sɛnea display: none
ɛte no ka ho. Borrowing an idea from PureCSS , yɛtu mpɔn wɔ saa default yi so denam yɛ a yɛbɛyɛ [hidden] { display: none !important; }
de aboa ma wɔasiw ne display
kwan sɛ ɛbɛba so wɔ akwanhyia mu no so.
<input type="text" hidden>
jQuery a ɛne ne ho nhyia
[hidden]
no ne jQuery's $(...).hide()
ne $(...).show()
akwan horow no nhyia. Enti, mprempren yɛnyɛ titiriw endorse [hidden]
over akwan afoforo a wɔfa so di display
of elements no ho dwuma.
Sɛ wopɛ sɛ wodannan element bi a wotumi hu no ara kwa, a ɛkyerɛ display
sɛ wɔansakra ne na element no da so ara tumi nya krataa no nsu a ɛsen no so nkɛntɛnso a, fa adesuakuw no.invisible
di dwuma mmom.