Beginning css preprocessors



Download 2,42 Mb.
Pdf ko'rish
bet53/59
Sana01.01.2022
Hajmi2,42 Mb.
#285229
1   ...   49   50   51   52   53   54   55   56   ...   59
Bog'liq
Beginning CSS Preprocessors

Listing 3-52.  Output of Listing 

3-53

.

.container {



  color: cyan;

}



Chapter 3 

 advanCed SaSS



54

grayscale($color)

This function returns the grayscale version of a color. This is demonstrated in Listing 

3-53


.

Listing 3-53.  Example of grayscale

$fontcolor:#FFCC00;

.container{

  color:grayscale($fontcolor);

}

List Functions



One of the most important functions among the list functions is nth($list, $n). It’s used to fetch a single 

item from the list. Unlike with JavaScript, Sass lists start counting from 1.

Thus, nth(10px 20px 30px, 1) will return 10px as a result.

Another important function is join. join($list1, $list2, [$separator]) is used to generate a new 

list by combining two lists. Each value in the list counts as a single item, and the function can also be used to 

make lists out of individual items. The optional $separator argument determines which type of list it should 

be; it can be a space or a comma. If it’s left out, the $list1 type is used.

Another simple yet important function is length($list). It returns the number of items in $list. So 

length(10 22 33) is 3.

User-Defined Functions

The @function directive is used for defining your own function. This can be useful when you want to 

perform actions that are not natively supported. @function is similar to @mixin, except that @function 

returns a result.

The @return directive is an important component of @function, which has a behavior similar to return 

in JavaScript. It accepts Sass expressions, processes them, and returns the result. Additionally, it stops the 

function execution after @return is triggered.

Consider a simple example of building a function. This example writes a function that generates width 

per column based on the number of columns provided, as shown in Listing 

3-54

.


Download 2,42 Mb.

Do'stlaringiz bilan baham:
1   ...   49   50   51   52   53   54   55   56   ...   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