Mixin CSS yog dab tsi?
Mixin CSS yog dab tsi?

Video: Mixin CSS yog dab tsi?

Video: Mixin CSS yog dab tsi?
Video: Om God op 'n afstand te dien - Eks 32 v 1-35 2024, Kaum ib hlis
Anonim

Mixins . A mixin cia koj ua pab pawg CSS cov lus tshaj tawm uas koj xav rov siv dua thoob plaws hauv koj qhov chaw. Koj tuaj yeem hla dhau qhov tseem ceeb los ua koj li mixin hloov tau ntau dua. Kev siv zoo ntawm a mixin yog rau cov neeg muag khoom ua ntej.

Raws li txoj cai, Kuv yuav siv Mixins hauv CSS li cas?

Tsim mixins ntawm @ mixin txoj cai Mixins tso cai rau cov kws sau ntawv los txhais cov qauv ntawm cov khoom muaj nqis khub, uas tuaj yeem rov qab siv dua hauv lwm cov cai. Cov mixin lub npe yog tus xaiv chav kawm uas txheeb xyuas qhov mixin raug tshaj tawm. Cov @ mixin lo lus tseem ceeb yuav tsum ua raws li mixin npe thiab daim ntawv tshaj tawm thaiv.

Tsis tas li ntawd, Mixins hauv SCSS yog dab tsi? Mixins tso cai rau koj los txhais cov qauv uas tuaj yeem rov siv tau thoob plaws hauv koj daim ntawv teev npe. Lawv ua kom yooj yim kom tsis txhob siv cov chav kawm tsis yog semantic xws li. ntab-sab laug, thiab faib cov ntawv sau ntawm cov qauv hauv cov tsev qiv ntawv. A mixin cov npe tuaj yeem yog ib qho Sass tus cim, thiab nws tuaj yeem muaj cov lus tshaj tawm uas tsis yog cov lus tshaj tawm.

Hais txog qhov no, koj siv Mixins li cas?

Rau siv a Mixin , peb yooj yim siv @include ua raws li lub npe ntawm tus Mixin thiab semi-colon. Tom qab muab SCSS code rau hauv CSS, peb cov ntaub ntawv CSS yuav tsum zoo li no.

Vim li cas koj thiaj yuav siv cov mixin?

Mixin . Mixins txhawb kom code rov siv dua thiab ua tau ua siv rau zam lub qub txeeg qub teg ambiguity uas ntau yam qub txeeg qub teg ua tau ua rau ("pob zeb diamond teeb meem"), los yog rau ua haujlwm ib puag ncig tsis muaj kev txhawb nqa rau ntau yam qub txeeg qub teg hauv ib hom lus. A mixin tau kuj yuav raug saib raws li ib tug interface nrog siv txoj kev.

Pom zoo: