Qala bocha
Qala hape, pokello ea liphetoho tsa CSS tse ikhethileng faeleng e le 'ngoe, kickstart Bootstrap ho fana ka motheo o motle, o tsitsitseng le o bonolo oa ho haha holima.
Atamela
Reboot e haha holim'a Normalize, e fana ka likarolo tse ngata tsa HTML tse nang le mekhoa e itseng e nang le maikutlo a sebelisa likhetho tsa likarolo feela. Setaele se eketsehileng se etsoa feela ka lihlopha. Ka mohlala, re qalisa <table>
mekhoa e meng bakeng sa motheo o bonolo 'me hamorao re fane ka .table
, .table-bordered
, le tse ling.
Mona ke litataiso tsa rona le mabaka a ho khetha seo u lokelang ho se ngola ho Reboot:
- Ntlafatsa litekanyetso tse ling tsa kamehla tsa sebatli hore u li sebelise
rem
s ho e-na leem
s bakeng sa sebaka se ka fokotsoang sa likarolo. - Qoba
margin-top
. Meeli e otlolohileng e ka putlama, 'me ea hlahisa litholoana tse sa lebelloang. Habohlokoa le ho feta, tataiso e le 'ngoemargin
ke mohlala o bonolo oa kelello. - Bakeng sa ho eketsa boholo ba lisebelisoa habonolo, likarolo tsa block li lokela ho sebelisa
rem
s bakeng samargin
s. - Boloka liphatlalatso tsa
font
thepa e amanang le tsona bonyane, u sebeliseinherit
neng kapa neng ha ho khoneha.
Mefuta e fapaneng ea CSS
E kentsoe ho v5.2.0Ka v5.1.1, re ile ra leka-lekanya @import
s ea rona e hlokahalang ho liphutheloana tsohle tsa rona tsa CSS (ho kenyeletsoa bootstrap.css
, bootstrap-reboot.css
, le bootstrap-grid.css
) ho kenyelletsa _root.scss
. Sena se eketsa :root
mefuta e fapaneng ea CSS ho liphutheloana tsohle, ho sa tsotelehe hore na li sebelisoa tse kae ka har'a bongata boo. Qetellong Bootstrap 5 e tla tsoelapele ho bona mefuta e mengata ea CSS e eketsoa ha nako e ntse e feta, e le ho fana ka mokhoa oa sebele oa nako ea sebele ntle le tlhoko ea ho khutlisa Sass kamehla. Mokhoa oa rona ke ho nka mefuta ea rona ea mohloli oa Sass le ho e fetola mefuta ea CSS. Ka tsela eo, leha o sa sebelise mefuta e fapaneng ea CSS, o ntse o na le matla ohle a Sass. Sena se ntse se tsoelapele 'me se tla nka nako ho se phethahatsa ka botlalo.
Ka mohlala, nahana ka mefuta ena :root
ea CSS bakeng sa <body>
mekhoa e tloaelehileng:
@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};
Ha e le hantle, mefuta eo e sebelisoa ho Reboot joalo ka:
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
}
E u lumellang ho etsa litlhophiso tsa nako ea 'nete kamoo u ratang kateng:
<body style="--bs-body-color: #333;">
<!-- ... -->
</body>
Maqephe a kamehla
The <html>
and <body>
elements li nchafalitsoe ho fana ka likhetho tse betere tsa leqephe lohle. Ka ho khetheha:
- E
box-sizing
behiloe lefatšeng ka bophara holim'a elemente e 'ngoe le e 'ngoe-ho kenyeletsoa*::before
le*::after
, hoborder-box
. Sena se tiisa hore bophara bo phatlalalitsoeng ba element ha ho mohla bo fetisoang ka lebaka la padding kapa moeli.- Ha ho na motheo
font-size
o phatlalalitsoeng ho<html>
, empa16px
ho nahanoa (sebapali sa kamehla).font-size: 1rem
e sebelisoa molemong oa<body>
ho fana ka mokhoa o bonolo oa ho araba ka lipotso tsa media ha ho ntse ho hlompha likhetho tsa basebelisi le ho netefatsa mokhoa o fumanehang habonolo. Boemo bona ba sebatli bo ka hlakoloa ka ho fetola phetoho$font-size-root
.
- Ha ho na motheo
- The
<body>
e boetse e beha lefatše lohlefont-family
,font-weight
,line-height
, lecolor
. Sena se futsitsoe hamorao ke likarolo tse ling ho thibela ho se lumellane ha fonte. - Bakeng sa polokeho, e
<body>
na le taelo e phatlalalitsoengbackground-color
, e sa fetoheng ho#fff
.
Sekhahla sa mongolo oa tlhaho
Bootstrap e sebelisa "stack fonte ea matsoalloa" kapa "mokhoa oa fonte ea sistimi" bakeng sa ho fana ka mongolo o nepahetseng ho sesebelisoa se seng le se seng le OS. Lifonti tsa sistimi li entsoe ka ho khetheha ho nahanoa ka lisebelisoa tsa kajeno, ka ntlafatso e ntlafalitsoeng ea li-skrini, tšehetso ea fonte e fapaneng, le tse ling. Bala haholoanyane ka mekotla ea litlhaku tsa tlhaho sehloohong sena sa Smashing Magazine .
$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;
Hlokomela hore hobane mongolo oa fonte o kenyelletsa litlhaku tsa emoji, litlhaku tse ngata tse tloaelehileng tsa Unicode/dingbat li tla hlahisoa e le litšoantšo tse mebala-bala. Ponahalo ea bona e tla fapana, ho ipapisitse le setaele se sebelisitsoeng ho sebatli/sethala sa mongolo oa emoji, 'me li ke ke tsa angoa ke color
mekhoa efe kapa efe ea CSS.
Sena font-family
se sebelisoa ho ' <body>
me se jeoa lefa lefats'eng ka bophara ho Bootstrap. Ho chencha lefatše font-family
, ntjhafatsa $font-family-base
le ho bopa Bootstrap.
Lihlooho le lirapa
Lintlha tsohle tsa sehlooho-mohlala, <h1>
-'me <p>
li hlophisoa bocha hore li margin-top
tlosoe. Lihlooho li margin-bottom: .5rem
kentse le lirapa margin-bottom: 1rem
bakeng sa sebaka se bonolo.
Sehlooho | Mohlala |
---|---|
<h1></h1> |
h1. Sehlooho sa Bootstrap |
<h2></h2> |
h2. Sehlooho sa Bootstrap |
<h3></h3> |
h3. Sehlooho sa Bootstrap |
<h4></h4> |
h4. Sehlooho sa Bootstrap |
<h5></h5> |
h5. Sehlooho sa Bootstrap |
<h6></h6> |
h6. Sehlooho sa Bootstrap |
Melao e tshekaletseng
The <hr>
element e nolofalitsoe. Ka mokhoa o ts'oanang le lits'oants'o tsa sebatli, <hr>
s li entsoe ka mokhoa oa border-top
, li na le kamehla opacity: .25
, 'me li rua lefa la tsona border-color
ka color
, ho kenyelletsa le hore color
na li behiloe neng ka motsoali. Li ka fetoloa ka lisebelisoa tsa mongolo, moeli, le opacity.
<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">
Manane
Mathathamo ohle— <ul>
, <ol>
, le <dl>
— a margin-top
tlositsoe le a margin-bottom: 1rem
. Mathathamo a senyehileng ha a na margin-bottom
. Re boetse re seta padding-left
lisebelisoa <ul>
le li- <ol>
element.
- Manane ohle a tlositsoe moeli oa ona o kaholimo
- 'Me moeli oa bona o tlase o tloaelehile
- Manane a Nested ha a na moeli o ka tlase
- Ka tsela ena ba na le ponahalo e eketsehileng
- Haholo-holo ha e lateloa ke lintlha tse ling tsa lenane
- Leqele le letšehali le lona le setiloe bocha
- Lenane le laetsoeng ke lena
- Ka lethathamo la lintho tse seng kae
- E na le ponahalo e tšoanang ka kakaretso
- Joalo ka lethathamo le sa reroang le fetileng
Bakeng sa setaele se bonolo, maemo a hlakileng a maemo, le sebaka se betere, manane a litlhaloso a ntlafalitsoe margin
s. <dd>
s reset margin-left
ho 0
le ho eketsa margin-bottom: .5rem
. <dt>
s ba sebete .
- Manane a tlhaloso
- Lethathamo la litlhaloso le nepahetse bakeng sa ho hlalosa mantsoe.
- Nako
- Tlhaloso ea lentsoe.
- Tlhaloso ea bobeli ea lentsoe le tšoanang.
- Lereho le leng
- Tlhaloso ea lentsoe lena le leng.
Inline khoutu
Qetella likotoana tse nyane tsa khoutu ka <code>
. Etsa bonnete ba hore u baleha li-angles tsa HTML.
<section>
e lokela ho phutheloa joalo ka inline.
For example, <code><section></code> should be wrapped as inline.
Diboloko tsa khoutu
Sebelisa <pre>
s bakeng sa mela e mengata ea khoutu. Hape, etsa bonnete ba hore u baleha masakaneng afe kapa afe a khoutu bakeng sa phetolelo e nepahetseng. The <pre>
element e setiloe bocha ho tlosa margin-top
le ho sebelisa rem
li-unit bakeng sa eona 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>
Lintho tse fapaneng
Bakeng sa ho bonts'a lintho tse fapaneng sebelisa <var>
tag.
<var>y</var> = <var>m</var><var>x</var> + <var>b</var>
Kenyelletso ea mosebelisi
Sebelisa lets'oao <kbd>
ho bonts'a keno eo hangata e kengoang ka keyboard.
Ho edita di-setting, tobetsa 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>
Sephetho sa mohlala
Bakeng sa ho bonts'a tlhahiso ea mohlala ho tsoa lenaneong sebelisa <samp>
tag.
<samp>This text is meant to be treated as sample output from a computer program.</samp>
Litafole
Litafole li fetotsoe hanyenyane ho ea ho setaele <caption>
s, ho putlama meeli, 'me li etsa bonnete ba hore li lumellana text-align
hohle. Liphetoho tse ling bakeng sa maliboho, padding, le tse ling li tla le .table
sehlopha .
Sehlooho sa tafole | Sehlooho sa tafole | Sehlooho sa tafole | Sehlooho sa tafole |
---|---|---|---|
Tafole sele | Tafole sele | Tafole sele | Tafole sele |
Tafole sele | Tafole sele | Tafole sele | Tafole sele |
Tafole sele | Tafole sele | Tafole sele | Tafole sele |
<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>
Mefuta
Likarolo tse fapaneng tsa liforomo li qaliloe bocha bakeng sa litaele tse bonolo. Tse ling tsa liphetoho tse hlokomelehang ke tsena:
<fieldset>
s ha e na meeli, padding, kapa margin kahoo e ka sebelisoa habonolo e le li-wrappers bakeng sa lintho tse kenang ka bomong kapa lihlopha tsa lintho tse kenang.<legend>
s, joalo ka li-fieldsets, le tsona li entsoe bocha hore li bontšoe joalo ka lihlooho tsa mefuta.<label>
s li behiloe hodisplay: inline-block
lumellamargin
ho sebelisoa.<input>
s,<select>
s,<textarea>
s, le<button>
s hangata li rarolloa ke Normalize, empa Reboot e tlosa tsonamargin
le ho behaline-height: inherit
, hape.<textarea>
s li fetotsoe hore e be boholo ba sebaka se otlolohileng feela kaha boholo bo tšekaletseng hangata bo "roala" sebopeho sa maqephe.<button>
s le<input>
likarolo tsa konopo li na lecursor: pointer
ha:not(:disabled)
.
Liphetoho tsena, le tse ling, li bontšoa ka tlase.
Tšehetso ea letsatsi le mebala
Hopola hore lintlha tsa letsatsi ha li tšehetsoe ka botlalo ke libatli tsohle, e leng Safari.
Litsupa holim'a likonopo
Reboot e kenyelletsa ntlafatso ea role="button"
ho fetola cursor ea kamehla ho pointer
. Kenya tšobotsi ena ho likarolo ho thusa ho bontša hore likarolo lia sebelisana. Karolo ena ha e hlokahale bakeng sa <button>
likarolo, tse fumanang cursor
phetoho ea tsona.
<span role="button" tabindex="0">Non-button element button</span>
Lintho tse fapaneng
Aterese
The <address>
element e nchafalitsoe ho seta sebopeho sa sebatli ho font-style
tloha italic
ho normal
. line-height
le hona joale le futsitsoe, ’me margin-bottom: 1rem
le ekelitsoe. <address>
s ke tsa ho hlahisa lintlha tsa ho ikopanya le baholo-holo ba haufi (kapa sehlopha sohle sa mosebetsi). Boloka fomete ka mela e qetellang ka <br>
.
1355 Market St, Suite 900
San Francisco, CA 94103
P: (123) 456-7890 Lebitso le
felletseng [email protected]
Blockquote
Ntho e sa lekanyetsoang margin
ho li-blockquotes ke 1em 40px
, kahoo re e khutlisetsa ho 0 0 1rem
ntho e 'ngoe e lumellanang le likarolo tse ling.
Qotsulo e tsebahalang, e fuperoeng ke karolo ea blockquote.
Motho ea tummeng ho Mohloli Title
Lintlha tse ka har'a mela
The <abbr>
element e fumana setaele sa mantlha ho etsa hore e hlahelle har'a litemana tsa serapa.
Kakaretso
Kakaretso cursor
ea kakaretso ke text
, kahoo re seta hape pointer
ho fetisa hore element e ka sebelisana le eona ka ho tobetsa ho eona.
Lintlha tse ling
Lintlha tse ling mabapi le lintlha.
Lintlha tse ling hape
Lintlha tse ling mabapi le lintlha ke tsena.
HTML5 [hidden]
tšobotsi
HTML5 e eketsa tšobotsi e ncha ea lefats'e e bitsoang[hidden]
, e ngotsoeng joalo display: none
ka kamehla. Ho alima mohopolo ho tsoa ho PureCSS , re ntlafatsa holim'a taba ena ka [hidden] { display: none !important; }
ho thusa ho e thibela hore e display
se ke ea hlakoloa ka phoso.
<input type="text" hidden>
jQuery ho se lumellane
[hidden]
ha e tsamaisane le jQuery's $(...).hide()
le $(...).show()
mekhoa. Ka hona, hajoale ha re khothaletse haholo [hidden]
mekhoa e meng ea ho laola display
likarolo.
Ho fetola ponahalo ea ntho e itseng feela, ho bolelang hore display
ha e ea fetoloa, 'me ntho e ntse e ka ama ho phalla ha tokomane, sebelisa sehlopha ho e-na le.invisible
hoo.