Cov txheej txheem:

Lub hauv paus tseem ceeb ntawm Lub Vev Xaib-raws li Lub Vev Xaib: 7 Kauj Ruam
Lub hauv paus tseem ceeb ntawm Lub Vev Xaib-raws li Lub Vev Xaib: 7 Kauj Ruam
Anonim
Lub hauv paus tseem ceeb ntawm Div-based Website
Lub hauv paus tseem ceeb ntawm Div-based Website
Lub hauv paus tseem ceeb ntawm Div-based Website
Lub hauv paus tseem ceeb ntawm Div-based Website

Cov lus qhia no yuav qhia koj cov hauv paus ntawm kev tsim lub vev xaib nrog divs. Vim tias cov ntxhuav siv rau kev teeb tsa yog qhov phem!: p Txhawm rau nkag siab cov lus qhia no, koj yuav tsum paub qhov yooj yim html thiab css. Yog tias koj tsis nkag siab qee yam, thov nug dawb. Kuv tus kheej lub vev xaib tseem siv hom kev faib ua haujlwm no.https://www.erwtje.netEnjoy

Kauj Ruam 1: Tsim Cov Ntaub Ntawv Yooj Yim

Tsim Cov Ntaub Ntawv Yooj Yim
Tsim Cov Ntaub Ntawv Yooj Yim

Ua ntej tsim koj cov ntaub ntawv html. Peb yuav ntxiv qhov pib yooj yim rau nws. Cov ntaub ntawv css yuav tsis muaj dab tsi rau tam sim no.html cov ntawv tam sim no muaj: sim Khaws koj cov ntaub ntawv html ua yam.html. Koj tuaj yeem xaiv lub npe koj tus kheej. Koj cov ntaub ntawv css yuav tsum tau khaws tseg ua.css. Nco ntsoov tias koj muab nws tib lub npe raws li tau hais hauv cov ntawv html. Hauv qhov xwm txheej no "style.css". Peb tam sim no muaj cov nplooj ntawv khoob khoob khoob thaum saib ua ntej hauv peb tus browser.

Kauj Ruam 2: Hloov Kho Lub Cev Tag rau Cov Xim Yooj Yim, Fonts, …

Kho kom raug lub cev Tag rau cov xim yooj yim, Fonts,…
Kho kom raug lub cev Tag rau cov xim yooj yim, Fonts,…

Peb yuav tso cov ntawv html raws li nws yog, thiab kho kom raug cov ntaub ntawv css. Ntxiv cov lej hauv qab no rau koj cov ntaub ntawv css: lub cev {keeb kwm yav dhau: #444444; font tsev neeg: verdana, arial, sans-serif; xim: #444444; font-loj: 12px; margin: 0px;} Nrog cov lej me me no peb yuav piav qhia txhua yam khoom ntawm lub cev tag. Txij li tag nrho cov ntsiab lus nyob hauv lub cev tag, cov teeb tsa no yuav cuam tshuam rau nplooj ntawv tag nrho. Qhov keeb kwm yav dhau thiab font xim (xim), tau teeb tsa rau xim grey. Qhov tsev neeg font (tsev neeg-tsev neeg) tau teeb tsa rau verdana. Yog tias lub khoos phis tawj siv los saib peb lub vev xaib tsis muaj font "verdana", nws yuav tso saib peb lub xaib hauv font "arial". Koj tuaj yeem ntxiv ntau fonts rau daim ntawv. Qhov "sans-serif" yog hom dav dav uas yuav siv thaum tsis muaj font uas koj tau muab rau. Cov font loj (font-size) tau teev rau 12 pixels. Qhov no yog qhov muaj nuj nqis. Yog tias koj xav hloov kho lwm qhov font-size (zoo li lub taub hau, kab lus, cov ntawv qhia zaub mov, …) koj tuaj yeem siv chav tsev txheeb ze "em" hloov chaw ntawm "px". Txoj kev no, yog tias koj xav hloov koj lub vev xaib, koj tsuas yog yuav tsum tau hloov lub cev font loj. Qhov paj tau raug teeb tsa rau 0px rau tag nrho plaub sab ntawm lub cev tag. Qhov no yog ua kom ntseeg tau tias lub xaib yuav lo rau saum lub qhov rais.

Kauj Ruam 3: Ntxiv Lub Thawv Nrog Lub Taub Hau thiab Cov Ntsiab Lus

Ntxiv Cov Thawv Nrog Lub Hau thiab Cov Ntsiab Lus
Ntxiv Cov Thawv Nrog Lub Hau thiab Cov Ntsiab Lus

Tam sim no peb yuav ntxiv lub thawv. Qhov no tsuas yog ib qho kev sib faib nyob nruab nrab uas yuav muaj peb lub vev xaib Hauv qhov ntim no, peb yuav ntxiv ob qho ntxiv; cov ntsiab lus div thiab header div. Our html cov ntaub ntawv yuav tam sim no zoo li no: kuaj Cov Ntsiab Lus Header Peb yuav ntxiv cov cai hauv qab no rau peb cov ntaub ntawv css: div#thawv {dav: 800px; npoo: 0px pib; keeb kwm yav dhau: #FFFFFF; padding: 0px;} div#cov ntsiab lus {dav: 800px; padding-top: 100px; tom qab: daj;} div#header {dav: 800px; qhov siab: 100px; tom qab: xiav; txoj hauj lwm: meej; sab saum toj: 0px;}. clearfix: tom qab {cov ntsiab lus: "."; zaub: thaiv; qhov siab: 0; meej: ob leeg; pom kev: zais;}. clearfix {display: inline-block;}/* Hide from IE Mac \*/. clearfix {display: block;} div#thawv txhais tau tias peb muaj daim ntawv faib nrog id "thawv". Peb yuav ntxiv qee qhov xim thiab "npoo: 0px pib;" kom paub tseeb tias peb lub ntim yog nyob rau ntawm nplooj ntawv. Peb yuav tsum muab cov ntsiab lus tso rau sab saum toj thiab lub taub hau tus nqi meej nrog "sab saum toj: 0px" kom paub tseeb tias lub taub hau nyob rau saum toj ntawm lwm cov ntsiab lus. cov xim tsis zoo Nws tsuas yog ua kom yooj yim nyeem cov xim thiab pom qhov sib txawv sib txawv. Peb yuav xav tau qhov coj txawv txawv coj txawv txawv kom paub tseeb tias peb cov kev taw qhia thiab cov ntsiab lus divs (ntxiv hauv cov kauj ruam tom ntej) tsis poob tawm ntawm ib puag ncig div.

Kauj Ruam 4: Ua Ob Qhov Sib Txawv hauv Cov Ntsiab Lus Sib Ntsib rau Kev Taw Qhia thiab Cov ntsiab lus tseeb

Ua Ob Qhov Sib Txawv hauv Cov Ntsiab Lus Div rau Kev Taw Qhia thiab Cov Ntsiab Lus
Ua Ob Qhov Sib Txawv hauv Cov Ntsiab Lus Div rau Kev Taw Qhia thiab Cov Ntsiab Lus

Tam sim no peb yuav ntxiv ob qhov sib ntxiv hauv cov ntsiab lus div. Ib qho rau kev taw qhia thiab ib qho rau cov ntsiab lus tseeb Hauv nruab nrab ntawm cov ntsiab lus-tag; koj yuav ntxiv cov cai tshiab:

Kev Tshawb Fawb Cov ntsiab lus Peb yuav ntxiv qee qhov css code los tso saib cov lus qhia thiab cov ntsiab lus tseem ceeb divs; div#nav {dav: 200px; ntab: sab laug; tom qab: txiv kab ntxwv;} div#maincontent {dav: 600px; ntab: yog; keeb kwm yav dhau: liab dawb;} Nco ntsoov qhov tseeb tias ob qho kev sib faib no yog ob qho tib si ntab. Yog tias peb tsis tau tso cai ntxiv cov lus piav qhia meej hauv cov kauj ruam dhau los, cov divs yuav ntab sab nraum ntawm ib puag ncig div. Nrog cov txheej txheem clearfix, peb yuav xyuas kom tsis txhob tshwm sim.

Kauj Ruam 5: Ntxiv Qee Qhov Ntxiv Ntxiv rau Tus Qauv hauv Kev Taw Qhia

Ntxiv Qee Qhov Ntxiv Ntxiv rau Tus Qauv hauv Kev Taw Qhia
Ntxiv Qee Qhov Ntxiv Ntxiv rau Tus Qauv hauv Kev Taw Qhia
Ntxiv Qee Qhov Ntxiv Ntxiv rau Tus Qauv hauv Kev Taw Qhia
Ntxiv Qee Qhov Ntxiv Ntxiv rau Tus Qauv hauv Kev Taw Qhia

Tam sim no peb yuav ntxiv qee qhov divs ntxiv rau ob qho "nav" div los tsim qee yam qauv hauv peb lub vev xaib. Hloov pauv me ntsis ntawm cov cai hauv qab no:

  • Foo
  • Bar

Tam sim no peb yuav tshaj tawm ib feem ntawm cov cai txhawm rau txheeb xyuas qhov faib "navblock" yuav tsum tau ua kom pom. Nco ntsoov tias navblock muaj chav kawm, tsis yog tus lej. Yog vim li cas rau qhov no yog qhov yooj yim; divs nrog tus lej tsuas yog tso tawm ib zaug (cov lus qhia thaiv, header, footer, …). Divs nrog cov chav kawm tuaj yeem pom ntau dua ib zaug. Ntawm no peb yuav siv chav kawm. Tsuas yog nyob rau hauv rooj plaub peb yuav xav ntxiv lwm txoj kev thaiv tom qab on.div.navblock {dav: 180px; npoo: 5px pib; ciam teb: 1px liab liab;} Yog tias peb xav ntxiv lwm qhov thaiv ntawm kev taw qhia, koj tsuas yog yuav tsum tau ntxiv ib qho tshiab… qauv. Koj cov cai tam sim no yuav zoo li no;

  • Foo
  • Bar
  • Boo
  • Nyob deb

Kauj Ruam 6: Ntxiv Qee Qhov Ntxiv Ntxiv rau Tus Qauv hauv Cov Ntsiab Lus Tseem Ceeb

Ntxiv Qee Qhov Ntxiv Ntxiv rau Tus Qauv hauv Cov Ntsiab Lus Tseem Ceeb
Ntxiv Qee Qhov Ntxiv Ntxiv rau Tus Qauv hauv Cov Ntsiab Lus Tseem Ceeb
Ntxiv Qee Qhov Ntxiv Ntxiv rau Tus Qauv hauv Cov Ntsiab Lus Tseem Ceeb
Ntxiv Qee Qhov Ntxiv Ntxiv rau Tus Qauv hauv Cov Ntsiab Lus Tseem Ceeb

Tam sim no peb yuav ua tib yam rau cov ntsiab lus tseem ceeb div. Code tam sim no zoo li no:

Lorem ipsum dolor sit amet,…

Ib zaug ntxiv, peb yuav ntxiv ib daim cai rau peb cov ntaub ntawv css los txiav txim siab li cas div yuav tsum tau tshwm sim: div.contentblock {dav: 580px; npoo: 5px pib; ciam teb: 1px tawv dawb;} Tam sim no peb tuaj yeem ntxiv lwm cov ntsiab lus los ntawm kev ntxiv lwm "…" hauv cov ntsiab lus tseem ceeb div zoo li no;

Lorem ipsum dolor sit amet,…

Nunc cursus, justo eget elementum dictum, …

Kauj Ruam 7: Ua rau Lub Vev Xaib Tsis Txaus Siab

Ua rau Lub Vev Xaib Tsis Txaus Siab Me
Ua rau Lub Vev Xaib Tsis Txaus Siab Me

Tam sim no qhov kev lom zem; xim tam sim no uas peb muaj cov qauv sib faib tseem ceeb, peb tuaj yeem hloov xim mus rau qee yam me ntsis tsis meej pem/dab tuag/… Tsuas yog ua si ib puag ncig nrog cov xim hauv cov ntawv css. Nov yog qhov ua tiav html cov ntaub ntawv ntawm lub vev xaib tso tawm hauv daim duab: xeem

  • Foo
  • Bar
  • Boo
  • Nyob deb

Lorem ipsum dolor sit amet,…

Nunc cursus, justo eget elementum dictum, …

Header Thiab qhov no yog qhov ua tiav css cov ntaub ntawv: lub cev {keeb kwm yav dhau: #444444; font tsev neeg: verdana, arial, sans-serif; xim: #444444; font-loj: 12px; margin: 0px;} div#thawv {dav: 800px; npoo: 0px pib; keeb kwm yav dhau: #FFFFFF; padding: 0px;} div#cov ntsiab lus {dav: 800px; padding-top: 100px; keeb kwm yav dhau: #FFFFFFF;} div #header {dav: 800px; qhov siab: 100px; keeb kwm yav dhau: #888888; txoj hauj lwm: meej; sab saum toj: 0px;} div#nav {dav: 200px; ntab: sab laug; keeb kwm yav dhau: #FFFFFFF;} div #maincontent {dav: 600px; ntab: yog; keeb kwm yav dhau: #DDDDDDD;} div.navblock {dav: 180px; npoo: 5px pib; ciam teb: 1px khoom #DDDDDDD;} div.contentblock {dav: 580px; npoo: 5px pib; ciam teb: 1px khoom #FFFFFF;}. clearfix: tom qab {cov ntsiab lus: "."; zaub: thaiv; qhov siab: 0; meej: ob leeg; pom kev: zais;}. clearfix {display: inline-block;}/* Hide from IE Mac \*/. clearfix {display: block;} Yog li tam sim no koj tau txais qhov pib. Tau kawg tseem muaj ntau yam los kho xws li xim, font-size, zoo dua saib navigation thaiv, … Tab sis cov ntawv qhia no tsuas yog hais txog cov qauv div. Yog tias koj xav pom lwm cov lus qhia muaj feem cuam tshuam, koj tuaj yeem nug ib txwm. Kuv mam saib yog tias kuv tuaj yeem nrhiav sijhawm.

Pom zoo: