Less hardlight

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

Less Color Blending hardlight()

The Less color blending hardlight function works similar to overlay function but but the role of the colors are interchanged. It performs an overlay () function with the second parameter to determine whether a multiply or screen operation should be done.


  • color1: It specifies a color object to overlay.

  • color2: It specifies a base color object which is the determinant color making the resultant color lighter or darker.

Returns: Resultant color

Hardlight Function Example

Let's take an example to demonstrate the usage of color blending hardlight function in Less file.

Create a HTML file named "simple.html", having the following data.

HTML file: simple.html


  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.    <title>Hardlight Function Example</title>  
  5.    <link rel="stylesheet" type="text/css" href="simple.css"/>  
  6. </head>  
  7. <body>  
  8. <h2>Example of Color Blending Hardlight Function</h2>  
  9. <div class="color1">  
  10.   <p>(color1) <br> #ff6600</p>  
  11. </div><br>  
  12. <div class="color2">  
  13.   <p>(color2) <br> #0000ff</p>  
  14. </div><br>  
  15. <div class="res">  
  16.   <p>(result) <br> #0000ff</p>  
  17. </div>  
  18. </body>  
  19. </html>  

Now create a file named "simple.less". It is similar to CSS file. The only one difference is that it is saved with ".less" extension.

LESS file: simple.less

  1. .color1 {  

  2.     width: 100px;  

  3.     height: 100px;  

  4.     background-color: #ff6600;  

  5. }  

  6. .color2 {  

  7.     width: 100px;  

  8.     height: 100px;  

  9.     background-color: #0000ff;  

  10. }  

  11. .res {  

  12.     width: 100px;  

  13.     height: 100px;  

  14.     background-color: hardlight(#ff6600, #0000ff);  

  15. }  

  16. p{  

  17.  padding: 30px 0px 0px 25px;  

  18.  color: white;  

  19. }

Put the both file "simple.html" and "simple.less" inside the root folder of Node.js

Now, execute the following code: lessc simple.less simple.css

Less Color blending hardlight function1

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

For example:

Less Color blending hardlight function2

The generated CSS "simple.css", has the following code:

  1. .color1 {  

  2.   width: 100px;  

  3.   height: 100px;  

  4.   background-color: #ff6600;  

  5. }  

  6. .color2 {  

  7.   width: 100px;  

  8.   height: 100px;  

  9.   background-color: #0000ff;  

  10. }  

  11. .res {  

  12.   width: 100px;  

  13.   height: 100px;  

  14.   background-color: #0000ff;  

  15. }  

  16. p {  

  17.   padding: 30px 0px 0px 25px;  

  18.   color: white;  

  19. }  


Less Color blending hardlight function3