CSS(Cascading Style Sheets) wani muhimmin bangare ne na ci gaban yanar gizo wanda ke taka muhimmiyar rawa wajen sarrafa abubuwan gani na abubuwan HTML akan gidan yanar gizon ku. Yana ba da ƙaƙƙarfan ƙaƙƙarfan ƙa'idodi da kaddarorin da ke ayyana yadda abubuwa ke nunawa, tsarawa, da matsayi, yana ba ku damar tsara kamanni da jin daɗin shafukan yanar gizon ku.
Bari mu fara da fahimtar manufar masu zaɓe
Ana amfani da masu zaɓe don ƙaddamar da takamaiman abubuwan HTML don salo. Ɗaya daga cikin mafi mahimmancin masu zaɓe shine mai zaɓin element, wanda ke zaɓar duk misalan wani nau'in HTML.
Misali, dokar CSS mai zuwa tana hari ga duk sakin layi a cikin takarda:
p {
color: blue;
}
A cikin wannan misalin, p
mai zaɓin yana zaɓar duk <p>
abubuwa kuma ya saita launin rubutun su zuwa shuɗi.
Wani zaɓi na gama gari shine mai zaɓen aji
Ana amfani da azuzuwan don haɗa abubuwan da ke da halaye iri ɗaya. Ta hanyar sanya aji zuwa abubuwan HTML, zaku iya niyya da salo da su gaba ɗaya.
Ga misali:
.blue-text {
color: blue;
}
A wannan yanayin, .blue-text
mai zaɓin ya zazzage duk abubuwa tare da ajin blue-text
kuma yana amfani da launin shuɗi akan rubutunsu.
Bugu da ƙari, ID
mai zaɓi yana ba ku damar yin niyya ta musamman ta hanyar ganowa ta musamman. ID
yawanci ana sanya su ga abubuwa guda ɗaya akan shafi.
Ga misali:
#header {
background-color: gray;
}
A cikin wannan misalin, #header
mai zaɓin zai zaɓi nau'in da ke ID header
da kuma yana amfani da launi mai launin toka.
Ci gaba zuwa tsarin tsarin CSS, kowace ka'idar CSS ta ƙunshi mai zaɓe da toshewar sanarwa.
Tushen shela an lullube shi cikin takalmin gyaran kafa mai lanƙwasa {}
kuma ya ƙunshi shela ɗaya ko fiye. Sanarwa ta ƙunshi dukiya da ƙimarta daidai.
Ga misali:
h1 {
font-size: 24px;
color: #333;
}
A cikin wannan snippet code, h1
mai zaɓin ya zaɓi duk <h1>
abubuwa kuma ya saita girman rubutun su zuwa pixels 24 da launi rubutu zuwa launin toka mai duhu(#333).
A cikin wannan silsilar, za mu bincika da kuma bayyana kaddarorin CSS iri-iri, masu zaɓe, da haɗe-haɗensu, wanda zai ba ku damar ƙirƙirar gidajen yanar gizo masu kyan gani da ingantaccen tsari. Fahimtar CSS da ainihin ma'anarsa zai ba ku tushe don sarrafa nau'ikan salo na shafukan yanar gizon ku, tabbatar da ƙwarewar mai amfani na musamman da keɓaɓɓen. Bari mu nutse a ciki mu gano yuwuwar CSS marasa iyaka!