RorohikoHōtaka

Preprocessor CSS: tirohanga whānui, kōwhiringa, tono

Tino whakamahi katoa kaihoahoa tukutuku mātau te Preprocessor. E kore okotahi. Ki te hiahia koe ki te angitu i roto i tenei mahi, e kore e wareware e pā ana ki ēnei hōtaka. I para tuatahi, kia meinga ratou he wehi ata tauhou - ko reira rite rawa ki te hōtaka! I roto i te meka, ka taea e koe te mahi ki nga āhuatanga katoa o te CSS Preprocessor mo e pā ana ki te ra, a ki te tamata koe, o haora ka te tokorua. I roto i te heke mai, ka tino faaohie ratou i to outou ora.

Kia pehea te i CSS Preprocessor

Hei mahino pai te āhuatanga o tenei hangarau, ruku poto ki te hītori o te whakaaturanga ataata o ngā whārangi Tukutuku.

A, no te anake tika timata te whakamahi nui o te Internet, kihai i te tīariari kahore rau kāhua. Tuhinga o tuhinga tei katoa i runga i te pūtirotiro. i Ia o ratou ratou ake momo, e kua whakamahia mo te maimoatanga o etahi tūtohu. Nä, i te whārangi titiro rerekē i runga i te tikanga i roto i nei te pūtirotiro whakatuwhera koe ratou rānei. Ko te hua - te hepohepo, te whakama, raruraru hoki ngā.

I roto i te 1994, whakawhanakehia pūtaiao Norwegian Håkon Takoto he whārangi kāhua e taea te whakamahi mo te ahua o nga whārangi motuhake i te HTML-tuhinga. Ko te priglanulas whakaaro ngā mema o te W3C, e whakaturia tonu atu ki te otinga. He tau torutoru i muri whakaputaina e ia he putanga tuatahi o te whakatakotoranga CSS. Na ka ake ia tonu, he oti ... Otiia noho te ariā te taua katoa: whakaturia kāhua ia etahi āhuatanga.

Mā te tepu CSS kua tonu kua raruraru. Hei tauira, maha i kaihoahoa tukutuku raruraru ki kōmaka me te whakarōpū ngā āhuatanga, a kahore he pera ohie tupu.

Na ka haere mai te mano e rua. Kei te piki timata tohu ki te whai wāhi i roto i ngā mua-mutunga ngaio, i te mea nui ki te hei kāhua ngāwari, me te hihiri mahi. Vai i te whakanohonga wa ui arohere CSS me te aroturuki tautoko nga kaha hou o te pūtirotiro. Na, i JavaScript, a ka ki raro, ki te mahi Ruby tohunga, te hanga i te Preprocessor - superstructure mō te CSS, āhuatanga hou e tapiritia ki reira.

CSS hoki Beginners: āhuatanga Preprocessor

E ratou e rave rahi mahi:

  • whakakotahi pīmua pūtirotiro me te khaki;
  • faaohie wetereo;
  • hoatu te whai wāhi ki te mahi ki Tīpako tauroto kahore hapa;
  • whakapai ake arorau styling.

I roto i te poto: tāpiri te Preprocessor CSS kaha hōtaka arorau. Na, e kore e whakamana i styling i roto i te rārangi mua o momo, me te ki te torutoru tikanga ohie me huarahi: taurangi, mahi, tuere, huringa tikanga. I tua atu, ki te kaha te whakamahi i te pāngarau.

Te kitenga i te rongonui o enei tāpiri-mai, kua tīmata te W3C ki āta tāpiri i te taea o ratou i roto i te waehere CSS. Hei tauira, i roto i te whakatakotoranga kia reira Tātaitai () mahi, tautokona nei e pūtirotiro maha. E tika ana e hohoro ka waiho reira taea ki te whakatakotoria taurangi, me te hanga i te tuere. Heoi, ka tupu tenei i roto i te heke mai tawhiti, me preprocessors kua konei a kua mahi pai.

Popular preprocessors CSS. Sass

Hangaia i roto i te 2007. Tuatahi he wae Haml - he HTML tātauira. āhuatanga hou mō te huānga CSS whakahaere ngā relished i runga i te Ruby i te auri tereraa, i timata ki te horapa i te reira mau vahi atoa. Ko te Sass he maha nui o ngā āhuatanga e kua whakaurua nei i roto i tetahi Preprocessor: taurangi, tāmau o Tīpako, tuere (Na, Heoi, e taea e kore te tāpiri i enei tautohetohe).

E whakaatu ana ngā taurangi i roto i te Sass

Taurangi whakaaturia ki te tohu $. Ka taea e ratou te pupuri io ratou āhuatanga me huinga, hei tauira: "$ borderSolid: 1px whero mārō;". I roto i tenei tauira, whakaaturia matou he tāupe huaina borderSolid, a whakaorangia ona utu e whero 1px totoka. Na, ki te mea i roto i te CSS hiahia tatou ki te hanga i tētahi whanui rohe whero o 1px, tohu noa taua tāupe i muri i te ingoa taonga. I muri i te fanongonongo o te taurangi e kore e taea te huri. He maha ngā mahi hanga-i roto i. Hei tauira, e whakaatu i te tāupe ki te uara o te $ redcolor # FF5050. Na, i roto i te waehere CSS i te āhuatanga o tetahi huānga, te whakamahi i te reira ki te whakaturia te tae momotuhi: p {tae: $ redColor; }. E hiahia ana koe ki te whakamātau ki te tae? Whakamahia taumahi pouri mama ranei. meatia tenei e pera: p {tae: pouri i ($ redColor, 20%); }. Ka rite ki te hua, ka kia 20% mama te redColor tae.

Ko te maha ngā mahi Sass hanga-i roto i. Worth i te iti rawa te pānui i ratou, engari pai - ki te ako.

kōhanga

I mua, ki te tohu kōhanga i ki te whakamahi i te hoahoa roa, me te fiemālie. A feruri na e to tatou he Tauoti, i te mea p, a i roto i reira, i roto i te tahuri, whakaturia whanganga. Hoki te Tauoti, e ti'a ia tatou ki te whakaturia te tae momotuhi whero, mo te p - kōwhai, mo te whanganga - māwhero. I roto i te CSS angamaheni kia e mahi reira e whai ake:

Ritua {

tae: whero;

}

Ritua p {

tae: kōwhai;

}

Tauoti p whanganga {

tae: māwhero;

}

Ki te CSS Preprocessor riro katoa māmā me te ake kiato:

Ritua {

tae: whero;

p {

tae: kōwhai;

.span {

tae: māwhero;

}

}

}

Elements mooni "haumi" tetahi ki tetahi.

aronga Preprocessor

Mā te aronga @import taea kawemai kōnae. Hei tauira, to tatou kōnae fonts.sass e ai ta te momo mō ngā momotuhi. Tūhono reira ki te style.sass kōnae matua: @import 'momotuhi'. Mahi! Engari o te kōnae nui kotahi ki te momo i te torutoru e taea te whakamahi mō te uru tere, me te ngāwari ki te āhuatanga e hiahiatia ana e matou.

tuere

Ko tētahi o nga whakaaro tino ngā. āhei te reira kotahi raina ki te ui i te huinga o ngā āhuatanga. Mahi e whai ake nei:

@mixin largeFont {

momotuhi-whānau: 'Times New Roma';

momotuhi-rahi: 64px;

rārangi-teitei: 80px;

momotuhi-taimaha: maia;

}

Tuere ki te tono ki te huānga i te whārangi, te whakamahi i te @include fakahinohino. Hei tauira, e hiahia ana matou ki te tono i te reira ki te pane H1. E tatou te hanganga e whai ake nei: H1 {@include: largeFont; }

E whakaritea nga āhuatanga katoa o te tuere te huānga H1.

Preprocessor Iti

manatu wetereo Sass hōtaka. Ki te mea e rapu ana koutou mo te kōwhiringa e he pai atu hoki tīmata ako CSS, titiro hoki Iti. I hanga te reira i roto i 2009. Ko te āhuatanga matua - tautoko mō te CSS wetereo taketake, na tauhou ki Imposer hōtaka ka waiho reira māmā ki te ako.

Kua whakapuakina te taurangi te whakamahi i te tohu @. Hei tauira: @fontSize: 14px;. mahi kōhanga i runga i te mau parau tumu taua rite i roto i Sass. E kauwhautia tuere e whai ake: .largeFont () {momotuhi-whānau: 'Times New Roma'; momotuhi-rahi: 64px; rārangi-teitei: 80px; momotuhi-taimaha: maia; }. Hei te hono e kore te mea e tika ana ki te whakamahi i aronga Preprocessor - tāpiri noa te tuere hou hanga i roto i te āhuatanga o te huānga tīpakohia. Hei tauira: H1 {.largeFont; }.

Stylus

Tētahi atu Preprocessor. I waihangatia i te 2011 e te kaituhi taua, e hoatu i te ao te Jade, Express me ētahi atu hua whai hua.

Ka taea te whakaaturia ngā taurangi i roto i te ara e rua - rānei āta kakato ranei. Hei tauira: momotuhi = 'Times New Roma'; - he kōwhiringa paruhi. Ko $ momotuhi = 'Times New Roma' - mārama. E whakaaturia tuere me hono kakato. Ko te wetereo, ko te rite whai: redColor () tae whero. Na ka taea e tatou te tāpiri i te tūemi, no te tauira: redColor H1 ();.

Stylus i runga i mawhiti tuatahi kia mea he hano. Kei hea ko te "Māori" taiapa me ngā irapiko? Ko te mea e tika ana ki te rumakina e ki reira, riro katoa nui mārama. Kia mahara, Heoi, e te whanaketanga o tenei Preprocessor wā roa-e taea "wete" whakamahi koe i te wetereo CSS matarohia. Tenei te tahi mau taime ai raruraru ka he ki te mahi ki te kāhua "parakore".

He aha Preprocessor whiriwhiri?

I roto i te meka, he reira ... e kore e mea faufaa te reira. whakahere putanga katoa e pā ana ki te taua āhuatanga tika he rerekē te wetereo o ia. Ka tūtohu mātou ki te puta e whai ake:

  • ki te koutou - kaihātepe me te hiahia ki te mahi tahi me ngā kāhua e rua i roto i te waehere, te whakamahi i te Sass;
  • ki te koe - he coder me te hiahia ki te mahi tahi me ngā momo rite ki te tahora tikanga, e whakarongo ki te Iti;
  • ki te rite koe itinga, te whakamahi i te Stylus.

Hoki rerekē katoa o te maha mutunga o whare pukapuka ngā e taea faaohie noa atu whanaketanga. Kaiwhakamahi tūtohu Sass ki te whakarongo ki te Kāpehu - he taputapu kaha ki maha ngā āhuatanga hanga-i roto i. Hei tauira, i muri i te tāuta koe i te reira e kore e whai koe ki te manukanuka te kuhimua kaihoko putanga. mahi ki te mātiti ohie. He taputapu mō te mahi ki te puawai, sprites. ua faaite kē te whānuitanga tuere. Homai tenei taputapu o nga ra i te tokorua - kupu e whakaora koe he rota o te wā me te kaha i roto i te heke mai.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 mi.unansea.com. Theme powered by WordPress.