Mus kom ze
Kawm txog cov ntsiab cai, cov tswv yim, thiab cov tswv yim siv los tsim thiab tswj Bootstrap kom koj tuaj yeem kho tau yooj yim dua thiab txuas ntxiv rau koj tus kheej.
Thaum cov nplooj ntawv pib pib qhia txog kev nthuav qhia txog qhov project thiab nws muaj dab tsi, cov ntaub ntawv no tsom mus rau vim li cas peb ua tej yam peb ua hauv Bootstrap. Nws piav qhia peb lub tswv yim los tsim lub vev xaib kom lwm tus tuaj yeem kawm los ntawm peb, pab nrog peb, thiab pab peb txhim kho.
Pom ib yam dab tsi tsis zoo, lossis tej zaum yuav ua tau zoo dua? Qhib qhov teeb meem - peb xav tham nrog koj.
Peb yuav dhia mus rau hauv txhua qhov ntau ntxiv, tab sis nyob rau theem siab, ntawm no yog qhov qhia peb txoj hauv kev.
- Cheebtsam yuav tsum teb thiab mobile-ua ntej
- Cheebtsam yuav tsum tau ua nrog ib tug hauv paus chav kawm thiab txuas ntxiv los ntawm kev hloov cov chav kawm
- Lub xeev cov ntsiab lus yuav tsum ua raws li qhov z-index scale
- Thaum twg ua tau, nyiam qhov kev siv HTML thiab CSS tshaj JavaScript
- Thaum twg ua tau, siv cov khoom siv hluav taws xob ntau dua li cov qauv kev cai
- Thaum twg ua tau, tsis txhob ua raws li cov cai HTML nruj (cov menyuam yaus xaiv)
Bootstrap cov lus teb yog tsim los teb, ib txoj hauv kev uas feem ntau hu ua mobile-thawj . Peb siv lo lus no hauv peb cov ntaub ntawv thiab pom zoo nrog nws, tab sis qee zaum nws tuaj yeem dav dhau. Txawm hais tias tsis yog txhua feem yuav tsum tau teb tag nrho hauv Bootstrap, qhov kev teb no yog hais txog kev txo qis CSS overrides los ntawm kev thawb koj ntxiv cov qauv raws li qhov chaw pom loj dua.
Hla Bootstrap, koj yuav pom qhov no kom meej meej hauv peb cov lus nug xov xwm. Feem ntau, peb siv min-width
cov lus nug uas pib ua ntawv thov ntawm ib qho kev tawg tshwj xeeb thiab nqa mus los ntawm cov ntsiab lus siab dua. Piv txwv li, ib tug .d-none
siv los ntawm min-width: 0
infinity. Ntawm qhov tod tes, ib qho .d-md-none
siv los ntawm qhov nruab nrab breakpoint thiab nce.
Qee lub sij hawm peb yuav siv max-width
thaum ib qho kev sib koom ua ke ntawm qhov kev xav tau nws. Qee lub sij hawm, cov overrides no ua haujlwm tau zoo thiab lub hlwb meej dua los siv thiab txhawb nqa dua li rov sau cov haujlwm tseem ceeb ntawm peb cov khoom. Peb siv zog los txwv txoj hauv kev no, tab sis yuav siv nws qee lub sijhawm.
Ib cag ntawm peb Reboot, cross-browser normalization stylesheet, tag nrho peb cov qauv tsom siv cov chav kawm ua tus xaiv. Qhov no txhais tau hais tias kev khiav ceev ntawm hom selectors (xws li, input[type="text"]
) thiab cov chav kawm niam txiv extraneous (xws li, .parent .child
) uas ua rau cov qauv tshwj xeeb heev kom yooj yim override.
Yog li ntawd, cov khoom yuav tsum tau ua nrog ib tug hauv paus chav kawm ntawv uas muaj ib tug ntau yam, tsis yog-rau-tau overridden vaj tse-tus nqi khub. Piv txwv li, .btn
thiab .btn-primary
. Peb siv .btn
rau tag nrho cov qauv zoo li display
, padding
, thiab border-width
. Peb mam li siv cov kev hloov pauv xws .btn-primary
li ntxiv cov xim, keeb kwm yav dhau, xim ciam teb, thiab lwm yam.
Cov chav kawm hloov kho yuav tsum tsuas yog siv thaum muaj ntau yam khoom lossis qhov tseem ceeb uas yuav tsum tau hloov pauv ntawm ntau qhov sib txawv. Modifiers tsis tas yuav tsim nyog, yog li nco ntsoov tias koj tab tom khaws cov kab code thiab tiv thaiv tsis tsim nyog overrides thaum tsim lawv. Cov piv txwv zoo ntawm kev hloov kho yog peb cov chav kawm xim xim thiab qhov sib txawv loj.
Muaj ob z-index
qhov ntsuas hauv Bootstrap - cov ntsiab lus hauv ib qho khoom siv thiab cov khoom sib tshooj.
- Qee cov khoom hauv Bootstrap tau tsim nrog cov ntsiab lus sib tshooj los tiv thaiv ob tus ciam teb yam tsis tau hloov kho cov
border
cuab yeej. Piv txwv li, pawg khawm, pab pawg nkag, thiab pagination. - Cov Cheebtsam no qhia txog tus qauv
z-index
ntsuas0
los ntawm3
. 0
yog default (initial),1
yog:hover
,2
yog:active
/.active
, thiab ,3
yog:focus
.- Txoj hauv kev no phim peb qhov kev cia siab ntawm cov neeg siv khoom tseem ceeb tshaj plaws. Yog hais tias lub ntsiab yog tsom, nws yog nyob rau hauv saib thiab ntawm cov neeg siv cov xim. Cov ntsiab lus nquag yog qhov thib ob siab tshaj vim tias lawv qhia txog xeev. Hover yog qhov thib peb siab tshaj vim nws qhia cov neeg siv lub hom phiaj, tab sis yuav luag txhua yam tuaj yeem hovered.
Bootstrap suav nrog ntau yam khoom siv uas ua haujlwm raws li kev sib tshooj ntawm qee yam. Qhov no suav nrog, nyob rau hauv kev txiav txim siab tshaj plaws z-index
, dropdowns, tsau thiab nplaum navbars, modals, tooltips, thiab popovers. Cov khoom no muaj lawv tus kheej z-index
qhov ntsuas uas pib ntawm 1000
. Tus lej pib no yog random thiab ua haujlwm me me ntawm peb cov qauv thiab koj qhov project tus qauv kev cai.
Txhua qhov sib tshooj ua ke ua rau nws muaj z-index
nqis me ntsis hauv txoj hauv kev uas cov ntsiab lus UI feem ntau tso cai rau cov neeg siv tsom lossis hovered cov ntsiab lus kom nyob twj ywm hauv kev pom txhua lub sijhawm. Piv txwv li, ib qho modal yog cov ntaub ntawv thaiv (xws li, koj tsis tuaj yeem ua lwm yam kev nqis tes ua rau lub modal qhov kev txiav txim), yog li peb muab tso rau saum peb navbars.
Xav paub ntau ntxiv txog qhov no hauv peb z-index
nplooj ntawv layout .
Thaum twg ua tau, peb nyiam sau HTML thiab CSS dhau JavaScript. Feem ntau, HTML thiab CSS yog qhov muaj txiaj ntsig thiab nkag mus rau ntau tus neeg ntawm txhua qib kev paub sib txawv. HTML thiab CSS kuj tseem nrawm dua hauv koj lub browser dua li JavaScript, thiab koj tus browser feem ntau muab kev ua haujlwm zoo rau koj.
Lub hauv paus ntsiab lus no yog peb thawj chav kawm JavaScript API yog data
tus cwj pwm. Koj tsis tas yuav sau yuav luag txhua JavaScript los siv peb cov JavaScript plugins; xwb, sau HTML. Nyeem ntxiv txog qhov no hauv peb nplooj ntawv saib JavaScript .
Thaum kawg, peb cov qauv tsim los ntawm cov cwj pwm tseem ceeb ntawm cov ntsiab lus hauv lub vev xaib. Thaum twg ua tau, peb nyiam siv qhov browser muab. Piv txwv li, koj tuaj yeem muab cov .btn
chav kawm ntawm ze li ntawm txhua lub ntsiab lus, tab sis feem ntau cov ntsiab lus tsis muab cov nqi semantic lossis browser functionality. Yog li ntawd, peb siv <button>
s thiab <a>
s.
Tib yam mus rau ntau yam complex. Thaum peb tuaj yeem sau peb tus kheej daim ntawv lees paub plugin ntxiv cov chav kawm rau niam txiv lub ntsiab lus raws li kev nkag siab lub xeev, yog li tso cai rau peb kom style cov ntawv nyeem liab, peb nyiam siv cov :valid
/ :invalid
pseudo-cov ntsiab lus txhua qhov browser muab rau peb.
Cov chav kawm siv hluav taws xob - yav tas los pab hauv Bootstrap 3 - yog ib tus phooj ywg muaj zog hauv kev tawm tsam CSS bloat thiab cov nplooj ntawv tsis zoo. Cov chav kawm siv hluav taws xob feem ntau yog ib qho, tsis hloov pauv khoom ntiag tug-tus nqi sib koom ua ke qhia raws li chav kawm (xws li .d-block
sawv cev display: block;
). Lawv qhov kev thov tseem ceeb yog kev siv ceev thaum sau HTML thiab txwv qhov kev cai CSS koj yuav tsum sau.
Tshwj xeeb hais txog kev cai CSS, cov khoom siv hluav taws xob tuaj yeem pab tiv thaiv cov ntaub ntawv loj dua los ntawm kev txo koj cov khoom vaj khoom tsev uas feem ntau rov ua dua rau hauv ib chav kawm. Qhov no tuaj yeem muaj txiaj ntsig zoo ntawm qhov ntsuas hauv koj qhov project.
Txawm hais tias tsis yog ib txwm ua tau, peb siv zog kom tsis txhob ua dogmatic dhau ntawm peb cov cai HTML rau cov khoom. Yog li, peb tsom mus rau ib chav kawm hauv peb cov neeg xaiv CSS thiab sim zam cov menyuam xaiv tam sim ( >
). Qhov no ua rau koj yooj yim dua hauv koj qhov kev siv thiab pab ua kom peb cov CSS yooj yim dua thiab tsis meej.