Beginning css preprocessors



Download 2,42 Mb.
Pdf ko'rish
bet9/59
Sana01.01.2022
Hajmi2,42 Mb.
#285229
1   ...   5   6   7   8   9   10   11   12   ...   59
Bog'liq
Beginning CSS Preprocessors

Listing 1-4.  Creating and Using a Reusable Code Block in the Preprocessor

@mixin containerSettings {

        padding-bottom: 45px;

        text-align:center;

}

p {


        @include containerSettings;

}

footer {



        @include containerSettings;

}

 



Listing 1-5.  Output of Listing 

1-4


p {

  padding-bottom: 45px;

  text-align: center;

}

 



footer {

  padding-bottom: 45px;

  text-align: center;

}

CSS, which is the foundation of all preprocessors, has a steep learning curve when it comes to 



understanding how different properties work, understanding cascading, browser support for various 

properties, the selectors, the quirks, and so forth. In addition to all the previous points, consider that 

maintaining stylesheets in today’s complex interfaces is a big challenge too. 

Most of the time, stylesheets are immensely repetitive, with properties or groupings of properties, 

etc. The typical CSS file is a linear document. This makes a programmer from an object-oriented domain 

go crazy.

As per the DRY principle: Every piece of knowledge must have a single, unambiguous, authoritative 

representation in a system.



Chapter 1 

 IntroduCtIon to preproCessors



4

The simplest explanation of this is that redundancy in code can result in failure and can create 

confusion for developers. CSS does not follow the DRY principle. Most of the times, CSS files will contain 

repeated rules, declarations, and values. Developers are constantly writing the same snippets of code 

throughout their stylesheets.

CSS lacks features like variables, symbolic constants, conditionals, expressions over variables, and so 

on, that are available in all other programming languages.

The CSS preprocessor sits between your preprocessor-friendly file and the compiled CSS files, which 

will be served to the browser. CSS preprocessors allow you to write code as per the DRY principle, making it 

faster, efficient, and maintainable. The code is then compiled into regular CSS files via the command line or 

an application.

Consider the example in Listing 

1-6

. Modern browsers support RGBA (Red Green Blue Alpha) and 



HSLA (Hue Saturation Lightness Alpha) color values. However, you need to provide a fallback for older 

browsers. A common practice is to declare a hex value first and then the RGBA or HSLA value.




Download 2,42 Mb.

Do'stlaringiz bilan baham:
1   ...   5   6   7   8   9   10   11   12   ...   59




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish