Yog tias keeb kwm yav dhau los ntawm cov nplooj ntawv ntawm koj lub xaib muaj ib daim duab, uas muaj qhov dav ntawm lub xaib thiab tau muab khij rau kab ntsug, ces koj tuaj yeem hloov nws tsuas yog kho daim duab no hauv daim duab editor. Thiab yog tias keeb kwm yav dhau los tsim nyob rau hauv cov cai ntawm nplooj ntawv, tom qab ntawd lawv tuaj yeem hloov pauv siv cov lus qhia hauv qab no.
Cov Lus Qhia
Kauj ruam 1
Txhawm rau hloov cov keeb kwm yav dhau, koj yuav tsum xub txiav txim siab seb nws tau teeb tsa li cas tam sim no ntawm qhov chaw nplooj ntawv. Txhawm rau ua qhov no, qhib cov kab ntawv sau npe ntawm nplooj ntawv ntawm lub server. Qhov no tuaj yeem ua tiav nrog ib tus ntawv luam zoo tib yam, tus qauv Notepad yuav ua. Thiab yog tias koj siv qee qhov kev tswj hwm cov ntsiab lus, tom qab ntawd nplooj ntawv tuaj yeem kho kho ncaj qha nyob rau hauv browser siv cov ntawv sau ua nplooj. HTML code ntawm nplooj ntawv (HTML - HyperText Markup Language, "hypertext markup language") muaj cov kab nrog cov lus qhia rau qhov browser piav qhia txog hom, qhov pom thiab cov qauv ntawm txhua lub hauv paus ntawm nplooj ntawv web. Cov lus qhia no yog hu ua "cim npe" thiab lawv tau sib sau ua pawg, ib qho pib nrog pib pib thiab xaus nrog qhov kawg kawg. Raws li cov qauv HTML, koj tuaj yeem tsim cov nplooj ntawv keeb kwm yav dhau los hauv qhov qhib daim pib. Qhov no yog ua tiav los ntawm qhov muab cov bgcolor cwj pwm hauv nws: Ntawm no xim tom qab ntawm nplooj ntawv no tau teev rau xim ntsuab. Qee cov xim raws li cov qauv HTML muaj lawv cov npe - piv txwv li Chocolate los yog Gainsboro, tab sis feem ntau siv cov lej hexadecimal xim: Yog tias cov xim tom qab tau teev nyob hauv txoj kev no, koj yuav tsum pom lub cev cim hauv nplooj ntawv code thiab hloov bgcolor attribute. muaj nuj nqis nrog rau qhov koj xav tau.
Kauj ruam 2
Cov nplooj ntawv nrog cov tsim ntau cov nyom feem ntau siv CSS (Cascading Style Sheets) los piav qhia txog cov tsos. CSS yog hom lus tsim tshwj xeeb los piav txog qhov pom ntawm cov khoom hauv daim ntawv html. Cov blocks ntawm CSS-code tuaj yeem suav nrog nplooj ntawv nplooj ntawv, muaj nyob hauv cov ntawv cais nrog "css" txuas ntxiv thiab txuas nrog nplooj ntawv nrog cov kev qhia tshwj xeeb hauv nplooj ntawv qhov chaws. Koj yuav tsum pom qhov cim npe hauv nplooj code - yog tias nws yuav xa mus rau sab nraud cov ntaub ntawv, tom qab ntawd koj xav tau qhib cov ntaub ntawv no rau kev kho kom raug. Xws li qhov txuas yuav zoo li qhov no: @import "style.css"; Thiab yog tias cov ntawv tam sim ntawd raws li cov lus qhia, thiab tsis yog ib qhov txuas rau cov ntawv, ces koj yuav tsum kho cov qauv ntawm no. Hauv ob qho xwm txheej no, koj yuav tsum tau saib rau ntu ntawm cov lus piav qhia style uas hais txog lub cev ntawm daim ntawv - lub cev. Tab sis nyob rau hauv CSS lus, qhov no yuav tsis hu ua "tag" tab sis "tus xaiv", thiab nws yuav zoo li, piv txwv li, zoo li no:
lub cev {
xim tom qab: Ntsuab;
xim: Dawb;
}
Koj yuav tsum tau hloov cov nqi ntawm tom qab-xim parameter - nws teev cov xim tom qab ntawm nplooj ntawv. Thiab ntawm no, dhau mus, nws yog ib qho ua tau los qhia qee qhov xim ntxoov ntxoo los ntawm lub npe, tab sis nws zoo dua los siv hexadecimal nqi. Piv txwv li, tus nqi hexadecimal rau qhov ntxoov ntxoo Chocolate = # D2691E. Nws yog qhov ua tau kom qhia meej tsis yog xim, tab sis kuj yog daim duab rau tom qab: lub cev {
tom qab: Ntsuab url (img / bg.jpg) rov ua-x;
xim: Dawb;
} Ntawm no url (img / bg.jpg) txhais tau tias daim duab npe bg.jpg