Cov HyperText Markup Language (HTML) cov lus qhia uas tsim cov rooj muab tso rau hauv cov nplooj ntawv web muab ntau qhov kev txwv tsis pub ntxiv. Qhov no tso cai, tsis zoo li lwm cov khoom thaiv, los tsim qhov ntau thiab tsawg tsis yog siv CSS lus (Cascading Style Sheets lossis "Cascading Style Sheets"), tab sis kuj siv cov HTML nws tus kheej.
Cov Lus Qhia
Kauj ruam 1
Siv qhov dav qhov cwj pwm ntawm daim ntawv cim npe los qhia qhov dav ntawm lub rooj hauv pixels. Lub npe (HTML kev qhia) cov lus muaj qhov qhib (
) ntu, nruab nrab ntawm cov uas muaj cov cim npe uas tsim cov kab thiab hlwb ntawm lub rooj. Cov cim ntxiv (cov cwj pwm) tuaj yeem tso rau hauv daim pib qhib, cov npe ntawm uas rau txhua daim tshwj xeeb tau txiav txim siab los ntawm cov qauv thoob ntiaj teb. Rau cov lus cim npe, cov qauv no cia siv qhov dav ntawm tus cwj pwm, uas tau hais meej qhov dav ntawm qhov rooj hauv pixels. Cov HTML code ntawm lub rooj yooj yim nrog xws li daim ntawv qhia ib txhais qhov dav ntawm 500 pixels tuaj yeem zoo li no:
Thawj tes | Thib thib ntawm tes |
Kauj ruam 2
Ntxiv ib cim lub cim rau tus nqi ntawm cov dav ntaus tswv yim yog tias koj xav tau qhia meej txog qhov dav ntawm lub rooj ua feem pua dua li hauv pixels:
Thawj tes | Thib thib ntawm tes |
Thov nco ntsoov tias qhov feem pua no yuav tsis tas ua raws li qhov dav ntawm lub browser qhov rai. Cov qauv ntawm cov ntaub ntawv tseem ceeb ntawm no - ib yam li lub zes zes ua lub zes tsis tuaj yeem tsis loj dua qhov ib uas tau muab zes, yog li 100% ntawm lub rooj dav tsis tuaj yeem loj dua qhov dav ntawm niam txiv lub ntsiab. Piv txwv li, yog tias lub rooj hauv sab hauv div block, tom qab ntawd qhov dav ntawm qhov block no yuav muab coj los ua 100%.
Kauj ruam 3
Siv cov lus qhia piav qhia hom lus yog tias koj xav teem tib qhov dav rau cov ntxhuav hauv cov nplooj ntawv hauv ib qho chaw hauv cov cai. Txhawm rau ua qhov no, thawj qhov chaw hauv lub taub hau ib feem ntawm HTML code (nruab nrab ntawm thiab) cov npe qhib thiab kaw uas txwv cov lus CSS cov lus:
/ * CSS cov lus qhia yuav nyob ntawm no * /
Tom qab ntawd tso cov CSS hauv qab no rau ntawm cov cim npe: rooj {dav: 100px;} Ntawm no, cov lus qhia tau hais tias cov lus piav qhia tso rau hauv qhov nkhaus nkhaus yuav tsum tau siv rau txhua cov kab cim npe uas pom hauv nplooj ntawv kab. Zoo, qhov dav ntsuas qhov teeb tsa qhov dav. Ntawm no, ib yam nkaus thiab, koj tuaj yeem siv tus ntsuas qhov nruab nrab ua feem pua.
Kauj ruam 4
Qhia cov npe ntawm chav kawm nyob rau hauv CSS code thiab hauv HTML lub rooj tag yog tias koj yuav tsum qhia qhov dav tsis yog rau txhua cov ntxhuav, tab sis tsuas yog rau ib lossis ntau lub rooj. Piv txwv li, cia peb hais hauv chav kawm uas khij ib pawg ntawm cov rooj noj mov me me yog qhov me me. Tom qab ntawd cov lus piav qhia ntawm nws cov style yuav zoo li no: table.tiny {dav: 100px;} Thiab cov lus sib phim ntawm ib qho ntawm cov kab ntawv hauv HTML code yog li no:
Thawj tes | Thib thib ntawm tes |