Rov pib dua
Reboot, ib qho kev sau ntawm cov ntsiab lus tshwj xeeb CSS hloov pauv hauv ib cov ntaub ntawv, kickstart Bootstrap los muab qhov zoo nkauj, zoo ib yam, thiab cov hauv paus ntsiab lus yooj yim los tsim.
Mus kom ze
Reboot ua raws li Normalize, muab ntau lub ntsiab lus HTML nrog qee qhov kev xav zoo uas siv cov khoom xaiv nkaus xwb. Ntxiv styling tsuas yog ua nrog cov chav kawm. Piv txwv li, peb reboot ib co <table>
qauv rau ib tug yooj yim lub hauv paus thiab tom qab ntawd muab .table
, .table-bordered
, thiab ntau dua.
Nov yog peb cov lus qhia thiab cov laj thawj ntawm kev xaiv dab tsi los hla hauv Reboot:
- Hloov kho qee qhov browser default values siv
rem
s es tsis txhobem
s rau scalable tivthaiv sib nrug. - Zam
margin-top
. Vertical margins tuaj yeem tawg, ua rau cov txiaj ntsig tsis tau xav txog. Qhov tseem ceeb tshaj, txawm li cas los xij, ib qho kev taw qhia ntawmmargin
yog tus qauv kev puas siab ntsws yooj yim. - Txhawm rau kom yooj yim scaling hla qhov ntau thiab tsawg, thaiv cov ntsiab lus yuav tsum siv
rem
s raumargin
s. - Khaws cov lus tshaj tawm ntawm
font
cov khoom ntsig txog yam tsawg kawg nkaus, sivinherit
thaum twg los tau.
Nplooj ntawv defaults
Cov <html>
thiab <body>
cov ntsiab lus tau hloov kho kom muab cov nplooj ntawv zoo dua qub. Tshwj xeeb tshaj yog:
- Lub
box-sizing
ntiaj teb no tau teeb tsa rau txhua lub ntsiab lus - suav nrog*::before
thiab*::after
, rauborder-box
. Qhov no ua kom ntseeg tau tias qhov kev tshaj tawm dav ntawm lub ntsiab lus tsis tau tshaj vim padding lossis ciam teb.- Tsis muaj lub hauv paus
font-size
tau tshaj tawm rau ntawm<html>
, tab sis16px
yog assumed (qhov browser default).font-size: 1rem
yog siv rau ntawm qhov<body>
yooj yim teb hom-scaling ntawm cov lus nug xov xwm thaum saib xyuas cov neeg siv nyiam thiab ua kom muaj kev nkag tau yooj yim dua.
- Tsis muaj lub hauv paus
- Lub
<body>
kuj teev ib lub ntiaj teb nofont-family
,line-height
, thiabtext-align
. Qhov no tau txais txiaj ntsig tom qab los ntawm qee cov ntsiab lus los tiv thaiv font inconsistencies. - Rau kev nyab xeeb, tus
<body>
tau tshaj tawmbackground-color
, defaulting rau#fff
.
Native font pawg
Lub web fonts lub neej ntawd (Helvetica Neue, Helvetica, thiab Arial) tau poob rau hauv Bootstrap 4 thiab hloov nrog "neeg haiv neeg font pawg" rau cov ntawv nyeem zoo tshaj plaws ntawm txhua lub cuab yeej thiab OS. Nyeem ntxiv txog cov kab ntawv ib txwm nyob hauv kab lus Smashing Magazine .
Qhov no font-family
yog siv rau qhov <body>
thiab tau txais txiaj ntsig thoob ntiaj teb thoob plaws hauv Bootstrap. Txhawm rau hloov lub ntiaj teb font-family
, hloov kho $font-family-base
thiab rov ua dua Bootstrap.
Kab lus thiab kab lus
Tag nrho cov ntsiab lus - piv txwv li, <h1>
- thiab <p>
rov pib dua kom muaj lawv margin-top
tshem tawm. Cov ncauj lus tau margin-bottom: .5rem
ntxiv thiab kab lus margin-bottom: 1rem
kom yooj yim sib nrug.
Lub taub hau | Piv txwv |
---|---|
|
h 1. Bootstrap taub hau |
|
h 2. Bootstrap taub hau |
|
h 3. Bootstrap taub hau |
|
h 4. Bootstrap taub hau |
|
h 5. Bootstrap taub hau |
|
h 6. Bootstrap taub hau |
Cov npe
Tag nrho cov npe - <ul>
, <ol>
, thiab <dl>
- muaj lawv margin-top
tshem tawm thiab a margin-bottom: 1rem
. Nested lists tsis muaj margin-bottom
.
- Lorem ipsum dolor sit amet
- Consectetur adipiscing elit
- Integer molestie lorem thiab massa
- Facilisis nyob rau hauv pretium nisl aliquet
- Nulla volutpat aliquam velit
- Phasellus iaculis neque
- Purus sodales ultricies
- Vestibulum laoreet porttitor sem
- Ac tristique libero volutpat ntawm
- Faucibus porta lacus fringilla vel
- Aenean zaum amet erat nunc
- Eget porttitor lorem
- Lorem ipsum dolor sit amet
- Consectetur adipiscing elit
- Integer molestie lorem thiab massa
- Facilisis nyob rau hauv pretium nisl aliquet
- Nulla volutpat aliquam velit
- Faucibus porta lacus fringilla vel
- Aenean zaum amet erat nunc
- Eget porttitor lorem
Rau qhov yooj yim styling, meej hierarchy, thiab qhov sib nrug zoo dua, cov npe piav qhia tau hloov kho margin
s. <dd>
s rov pib dua margin-left
thiab 0
ntxiv margin-bottom: .5rem
. <dt>
s ua bold .
- Cov npe piav qhia
- Daim ntawv teev lus piav qhia zoo meej rau kev txhais cov ntsiab lus.
- Euismod
- Vestibulum id ligula porta felis euismod semper eget lacinia odio sem.
- Donec id elit non mi porta gravida at eget metus.
- Malesuada porta
- Etiam porta sem malesuada magna mollis euismod.
Cov ntawv nyeem ua ntej
Lub <pre>
caij yog rov pib dua kom tshem tawm nws margin-top
thiab siv rem
units rau nws margin-bottom
.
.example-element { margin-hauv qab: 1rem; }
Rooj
Cov ntxhuav tau hloov kho me ntsis rau style <caption>
s, tsoo ciam teb, thiab ua kom zoo ib yam text-align
thoob plaws. Ntxiv kev hloov pauv rau ciam teb, padding, thiab ntau ntxiv tuaj nrog rau .table
chav kawm .
Cov kab lus | Cov kab lus | Cov kab lus | Cov kab lus |
---|---|---|---|
Rooj cell | Rooj cell | Rooj cell | Rooj cell |
Rooj cell | Rooj cell | Rooj cell | Rooj cell |
Rooj cell | Rooj cell | Rooj cell | Rooj cell |
Cov ntawv
Ntau daim ntawv cov ntsiab lus tau rov pib dua rau cov qauv yooj yim. Nov yog qee qhov kev hloov pauv tseem ceeb tshaj plaws:
<fieldset>
s tsis muaj ciam teb, padding, lossis margin yog li lawv tuaj yeem siv tau yooj yim los ua wrappers rau ib tus neeg nkag lossis pab pawg ntawm cov khoom nkag.<legend>
s, zoo li fieldsets, kuj tau hloov kho kom pom raws li cov npe ntawm hom.<label>
s tau teem komdisplay: inline-block
tso caimargin
rau siv.<input>
s,<select>
s,<textarea>
s, thiab<button>
s feem ntau hais los ntawm Normalize, tab sis Reboot tshem tawm lawvmargin
thiab teeb tsaline-height: inherit
, ib yam nkaus.<textarea>
s yog hloov kho kom tsuas yog resizable vertically raws li kab rov tav resizing feem ntau "so" nplooj layout.
Cov kev hloov pauv no, thiab ntau ntxiv, tau pom hauv qab no.
Lwm yam
Chaw nyob
Lub <address>
caij yog hloov kho kom rov pib dua qhov browser default font-style
los ntawm italic
mus rau normal
. line-height
tseem tam sim no tau txais txiaj ntsig, thiab margin-bottom: 1rem
tau ntxiv lawm. <address>
s yog los nthuav qhia cov ntaub ntawv tiv tauj rau cov poj koob yawm txwv ze tshaj plaws (lossis tag nrho lub cev ua haujlwm). Khaws formatting los xaus kab nrog <br>
.
1355 Market St, Suite 900
San Francisco, CA 94103
P: (123) 456-7890 Lub Npe Lub Npe
[email protected]
Blockquote
Lub neej ntawd margin
ntawm blockquotes yog 1em 40px
, yog li peb rov pib dua qhov ntawd 0 0 1rem
rau ib yam dab tsi zoo sib xws nrog lwm cov ntsiab lus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat ante.
Cov ntsiab lus hauv kab
Lub <abbr>
caij tau txais cov qauv yooj yim los ua kom nws sawv hauv cov kab lus.
Cov ntsiab lus
Lub neej ntawd cursor
ntawm cov ntsiab lus yog text
, yog li peb rov pib dua qhov ntawd pointer
kom qhia tias lub caij tuaj yeem cuam tshuam nrog los ntawm txhaj rau nws.
Qee cov ntsiab lus
Xav paub ntau ntxiv txog cov ntsiab lus.
Txawm paub ntau ntxiv
Ntawm no yog cov ntsiab lus ntau ntxiv txog cov ntsiab lus.
HTML5 [hidden]
attribute
HTML5 ntxiv tus cwj pwm tshiab thoob ntiaj teb muaj npe[hidden]
, uas yog styled raws li display: none
lub neej ntawd. Qiv ib lub tswv yim los ntawm PureCSS , peb txhim kho raws li lub neej ntawd los ntawm kev ua [hidden] { display: none !important; }
los pab tiv thaiv nws display
los ntawm kev ua yuam kev overridden. Thaum [hidden]
tsis yog ib txwm txhawb nqa los ntawm IE10, cov lus tshaj tawm meej hauv peb CSS tau nyob ib puag ncig qhov teeb meem.
jQuery incompatibility
[hidden]
yog tsis sib xws nrog jQuery's $(...).hide()
thiab $(...).show()
txoj kev. Yog li ntawd, peb tsis tam sim no tshwj xeeb tshaj yog pom zoo [hidden]
rau lwm cov tswv yim los tswj cov display
ntsiab lus.
Txhawm rau tsuas yog toggle qhov pom ntawm lub ntsiab lus, lub ntsiab lus nws display
tsis hloov kho thiab lub ntsiab tseem tuaj yeem cuam tshuam rau qhov ntws ntawm cov ntaub ntawv, siv chav .invisible
kawm hloov.