In this chapter let's study about Type Functions. They are used to determine the type of the value.
Following table shows the Type Functions used in LESS.
Following table shows the Type Functions used in LESS.
S.N. | Type Functions & Description | Example |
---|---|---|
1 | isnumber It takes a value as parameter and returns true, if it's a number or false otherwise. |
isnumber(1234); // true isnumber(24px); // true isnumber(7.8%); // true isnumber(#fff); // false isnumber(red); // false isnumber("variable"); // false isnumber(keyword); // false isnumber(url(...)); // false |
2 | isstring It takes a value as parameter and returns true, if it's a string or false otherwise. |
isstring("variable"); // true isstring(1234); // false isstring(24px); // false isstring(7.8%); // false isstring(#fff); // false isstring(red); // false isstring(keyword); // false isstring(url(...)); // false |
3 | iscolor It takes a value as parameter and returns true, if value is a color or false if it's not. |
iscolor(#fff); // true iscolor(red); // true iscolor(1234); // false iscolor(24px); // false iscolor(7.8%); // false iscolor("variable"); // false iscolor(keyword); // false iscolor(url(...)); // false |
4 | iskeyword It takes a value as parameter and returns true, if value is a keyword or false if it's not. |
iskeyword(keyword); // true iskeyword(1234); // false iskeyword(24px); // false iskeyword(7.8%); // false iskeyword(#fff); // false iskeyword(red) ; // false iskeyword("variable");// false iskeyword(url(...)); // false |
5 | isurl It takes a value as parameter and returns true, if value is a url or false if it's not. |
isurl(url(...)); // true isurl(keyword); // false isurl(1234); // false isurl(24px); // false isurl(7.8%); // false isurl(#fff); // false isurl(red) ; // false isurl("variable"); // false |
6 | ispixel It takes a value as parameter and returns true, if value is a number in pixels or false otherwise. |
ispixel(24px); // true ispixel(1234); // false ispixel(7.8%); // false ispixel(keyword); // false ispixel(#fff); // false ispixel(red) ; // false ispixel("variable"); // false ispixel(url(...)); // false |
7 | isem It takes a value as parameter and returns true, if value is an em value or false if it's not. |
isem(0.5em); // true isem(1234); // false isem(24px); // false isem(keyword); // false isem(#fff); // false isem(red) ; // false isem("variable"); // false isem(url(...)); // false |
8 | ispercentage It takes a value as parameter and returns true, if value is in percentage or returns false, if value is not in percentage. |
ispercentage(7.5%); // true ispercentage(url(...)); // false ispercentage(keyword); // false ispercentage(1234); // false ispercentage(24px); // false ispercentage(#fff); // false ispercentage(red) ; // false ispercentage("variable"); // false |
9 | isunit It returns true if a value is a number in specified units provided as parameter or it will return false if value is not a number in specified units. |
isunit(10px, px); // true isunit(5rem, rem); // true isunit(7.8%, '%'); // true isunit(2.2%, px); // false isunit(24px, rem); // false isunit(48px, "%"); // false isunit(1234, em); // false isunit(#fff, pt); // false isunit("mm", mm); // false |
10 | isruleset It takes a value as parameter and returns true, if value is a ruleset or false otherwise. |
@rules: { color: green; } isruleset(@rules); // true isruleset(1234); // false isruleset(24px); // false isruleset(7.8%); // false isruleset(#fff); // false isruleset(blue); // false isruleset("variable"); // false isruleset(keyword); // false isruleset(url(...)); // false |
No comments:
Post a Comment