Kawm dab tsi CSS Selector

Pib CSS

CSS tso siab rau cov qauv kev cai sib txawv los txiav txim siab uas cov lus siv rau lub ntsiab lus hauv daim ntawv. Cov qauv no hu ua selectors thiab lawv sib txawv ntawm cov npe tag (piv txwv li, p pauv cov ntawv cim npe) rau cov qauv nyuab heev uas sib txawv heev ntawm cov ntaub ntawv (piv txwv li, p # myid> b.highlight yuav phim txhua tag nrog ib chav kawm ntawm qhov tseem ceeb uas yog ib tug me nyuam ntawm pawg lus nrog daim npav myid).

Ib tug CSS selector yog ib feem ntawm CSS cov qauv hu uas qhia txog qhov twg hauv qhov web page yuav tsum tau styled. Cov selector muaj ib qho los yog ntau lub zog uas txhais tau hais tias cov HTML HTML yuav zoo li cas.

Cov CSS Xaiv

Muaj ntau ntau hom kev xaiv:

Hom ntawv CSS thiab CSS xaiv

Lub hom CSS style zoo li no:

selector {style cuab yeej: style; }

Cais ntau cov selectors uas muaj tib lub style nrog huab cua. Qhov no hu ua selector grouping. Piv txwv li:

selector1 , selector2 {style property: style; }

Grouping selectors yog ib qho kev sib txig ntawm kev ua kom koj tus CSS tsis sib haum.

Cov saum toj no yuav muaj cov nyhuv tib yam li:

selector1 {style property: style; }
selector2 {style property: style; }

Nco ntsoov kuaj koj tus CSS xaiv

Tsis yog txhua tus browsers txhawb txhua tus CSS selectors. Yog li yuav tsum kuaj koj selectors rau hauv ntau browsers rau ntau lub operating systems li koj tau. Tab sis yog tias koj siv CSS 1 los yog CSS2 xaiv koj yuav tsum ua zoo.