Less ispixel

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Less ispixel()

The Less ispixel() function takes a value as a parameter and returns TRUE if the value is a pixel otherwise, returns FALSE.

isurl() Function Example

Let's take an example to demonstrate the usage of isurl() function in Less file.

Create a Less file named "simple.less", having the following code:

Less file: simple.less

  1. div {  

  2.     font:        ispixel(#ff0);            

  3.     background:  ispixel(blue);      

  4.     border:      ispixel("string");    

  5.     font:        ispixel(1234);      

  6.     background:  ispixel(56px);      

  7.     border:      ispixel(7.8%);            

  8.     border:      ispixel(keyword);                 

  9. }  

Now open the node.js command prompt and execute the following code: lessc simple.less simple.css

Less ispixel function1

This will compile the "simple.less" file. A CSS file named "simple.css" will be generated.

For example:

Less ispixel function2


Less ispixel function3

  1. div {  

  2.   background: false;  

  3.   font: false;  

  4.   background: true;  

  5.   border: false;  

  6. }