Yuav Ua Li Cas Teev Indentation

Cov txheej txheem:

Yuav Ua Li Cas Teev Indentation
Yuav Ua Li Cas Teev Indentation

Video: Yuav Ua Li Cas Teev Indentation

Video: Yuav Ua Li Cas Teev Indentation
Video: Yuav ua li cas By Nhia Lor [full version] 2024, Kaum ib hlis
Anonim

Feem ntau cov feem ntau, txhawm rau qhia qhov loj me ntawm indents hauv HTML-nplooj ntawv, lub peev xwm ntawm CSS lus (Cascading Style Sheets) yog siv. Txawm hais tias nyob hauv cov lus HTML nws tus kheej muaj ob peb "rudimentary" seem, tso cai rau qee qhov teeb tsa kev ua yeeb yam. Hauv qab no yog cov kev xaiv uas siv feem ntau, tab sis dhau li ntawm lawv tseem muaj ntau yam sib txawv uas tso cai rau koj teeb tsa kev nkag tau rau ntawm tsis siv tus cim ntawm HTML cov ntaub ntawv.

Yuav ua li cas teev indentation
Yuav ua li cas teev indentation

Nws yog qhov tsim nyog

Cov txuj ci yooj yim ntawm HTML thiab CSS hom lus

Cov Lus Qhia

Kauj ruam 1

Xav saib nplooj ntawv twg los thiaj nkag rau hauv. Piv txwv li, yog tias cov ntawv tso rau hauv cov ntawv sau … (block), ces qhov block no yuav yog qhov sib txig ua niam txiv rau cov ntawv no thiab kev nkag mus yuav tsum tau suav los ntawm cov ciam teb ntawm lub block. Thiab yog tias cov ntawv nyeem (lossis cov duab) tsis nyob sab hauv cov block (div, li, thiab lwm yam) lossis hauv kab (nrug, p, thiab lwm yam) cov ntsiab lus, ces nws niam nws txiv yuav yog daim ntawv lub cev (lub cev cim npe). Txhais cov niam txiv keeb kwm rau cov ntawv nyeem yog qhov tsim nyog vim tias nws yog nws leej twg yuav tsum tau tsim cov lus piav qhia ntawm cov qauv uas tsim cov cim. Cia peb xav tias koj cov ntawv yog muab tso rau sab hauv div block: Cov ntawv nyeem piv txwv

Kauj ruam 2

Siv CSS cov lus ntawm cov cuab yeej los tsim cov npoo, uas yog, qhov kev ncua deb ntawm tus ciam teb ntawm ib qho mus rau cov khoom uas nyob ib sab, nrog rau cov ciam teb ntawm niam txiv ntu. Qhov kev ncua deb no tuaj yeem tsim cais rau padding ntawm txhua sab: npoo-saum - rau saum, npoo-sab xis - ntawm sab xis, npoo-hauv qab - nyob rau hauv qab, npoo-sab laug - ntawm sab laug. Rau piv txwv li saum toj no, css code yuav zoo li qhov no: div {

paj tau paj-saum: 10px;

npoo-txoj cai: 15px;

npoo-hauv qab: 40px;

paj tau paj-laug: 70px;

} Ntawm no "div" yog tus xaiv uas hais tias qhov qauv no yuav tsum tau siv rau txhua divs ntawm cov ntawv cim. CSS syntax tso cai rau koj los sib sau ua plaub kab rau hauv ib qho: div {

cov npoo: 10px 15px 40px 70px;

} Cov qhov tseem ceeb ntawm txoj kab kos yuav tsum tau ib txwm teev nyob hauv qhov kev txiav txim no: thawj zaug - nyob rau sab saum toj, tom qab ntawd - ntawm sab xis, hauv qab thiab sab laug. ib zaug: div {

cov npoo: 70px;

} Ntxiv rau, koj tuaj yeem tsim lub ntab ntab ntab (uas yog, sab laug thiab sab xis). Qhov no tuaj yeem pab tau zoo thaum koj xav tau teeb tsa lub thaiv ntawm qhov muab dav dav raws nraim hauv nruab nrab ntawm qhov browser qhov rai. Qhov browser nws tus kheej cia txiav txim siab ntau npaum li cas indentation yuav tsum nyob rau ob sab, yog tias koj sau cov lus CSS nram qab no: div {

paj tau paj: 0 auto;

}

Kauj ruam 3

Siv cov cuab yeej padding los tsim padding, uas yog qhov kev ncua deb ntawm tus ciam ntawm ib qho mus rau ib qho ntsiab lus tso hauv nws, suav nrog cov ntawv sau. Cov syntax rau cov cuab yeej no yog tib yam li rau cov khoom ntiag tug: div {

padding-saum: 10px;

padding-txoj cai: 15px;

padding-hauv qab: 40px;

padding-laug: 70px;

} Or div {

padding: 10px 15px 40px 70px;

}

Kauj ruam 4

Siv cov ntawv nyeem-indent cov cuab yeej los teeb ntxiv indentation rau thawj kab ntawm txhua kab lus. Piv txwv li: div {

text-indent: 80px;

}

Kauj ruam 5

Siv hspace thiab vspace cov cwj pwm ntawm HTML img tag kom teeb kab rov tav thiab ntsug ntawm cov duab mus rau cov khoom sab nraud, feem. Piv txwv, zoo li qhov no:

Kauj Ruam 6

Siv cov cellpadding attribute ntawm lub rooj cim npe yog tias koj xav tau tsim kev nkag los ntawm ciam teb ntawm cov hlwb hauv lub rooj rau lawv cov ntsiab lus. Thiab cellspacing attribute teev qhov nrug ntawm lub rooj hlwb. Piv txwv li:

1 2

Pom zoo: