Less.js Color Operation fadein() Function
Last Updated :
06 Oct, 2022
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. It is better since CSS makes use of a dynamic style sheet language. LESS is flexible enough to work in a wide range of browsers. To create and improve CSS so that web browsers can use it, a computer language known as the CSS pre-processor is used. In addition, it is a CSS language extension that provides tools like variables, functions, mixins, and operations to help with the development of dynamic CSS while preserving backward compatibility.
In this article, we are going to discuss the Color Operation fadein() function in Less.JS, along with knowing their basic implementation through the illustration.
The fadein() function is to regulate the exact opacity of a color object. Opacity can be set or reset. So this function takes hex value, RGB value, HSL or HSV value and it returns a value with that required opacity.
Syntax:
fadein(color, amount)
Parameter values:
- color: This is the first parameter and it is compulsory, it can be a hex value, RGB value, HSL, or HSV value.
- amount: This parameter is also compulsory and it signifies the amount of opacity that is needed to be applied. This parameter takes a value from 0-100% range.
Please refer to the How to pre-compile LESS into CSS article for a detailed description.
Example 1: The below code example demonstrates the usage and implementation of the Color Operation fadein() function in Less.js.
HTML
<!DOCTYPE html>
< html >
< head >
< link rel = "stylesheet"
type = "text/css" href = "style.css" />
</ head >
< body >
< h1 style = "color:green;" >
GeeksforGeeks
</ h1 >
< h3 >Less.js Color Operation fadein() Function</ h3 >
< div class = "c1" >
< p >
fadein(hsl(90, 100%, 50%), 35%)< br >
(HSLA Value)< br >hsl(90, 100%, 50%)
</ p >
</ div >
</ body >
</ html >
|
styles.less
@body-bg- color : #eeeeee ;
body{
background-color : @body-bg-color;
}
.c 1 {
width : 250px ;
height : 150px ;
margin : 1 rem;
background-color : fadein(hsl( 90 , 100% , 50% ), 35% );
}
p{
padding : 40px 0px 0px 20px ;
}
|
Syntax: To compile the above LESS code to CSS code, run the following command:
lessc styles.less styles.css
style.css: The CSS output of the above Less file was compiled
style.css
body {
background-color : #eeeeee ;
}
.c 1 {
width : 250px ;
height : 150px ;
margin : 1 rem;
background-color : hsl( 90 , 100% , 50% );
}
p {
padding : 40px 0px 0px 20px ;
}
|
Output:
Example 2: The below code example demonstrates the usage and implementation of the Color Operation fadein() function with the if() and boolean logical functions and the color type function.
HTML
<!DOCTYPE html>
< html >
< head >
< link rel = "stylesheet"
type = "text/css" href = "style.css" />
</ head >
< body >
< h1 style = "color:green;" >
GeeksforGeeks
</ h1 >
< h3 >Less.js Color Operation fadein() Function</ h3 >
< div class = "c1" >
< p >
fadein(hsla(90, 100%, 50%, 0.2), 65%)< br >
(HSLA Value)< br >hsla(90, 100%, 50%, 0.85)
</ p >
</ div >
</ body >
</ html >
|
style.less
@body-bg- color : #eeeeee ;
@ color : hsl( 150 , 100% , 39% );
@second: rgb ( 58 , 21 , 11 );
@hex: fadein(hsla( 90 , 100% , 50% , 0.2 ), 65% );
@cond 1: boolean(iscolor(@hex));
body {
background-color : @body-bg-color;
}
.c 1 {
width : 250px ;
height : 150px ;
margin : 1 rem;
background-color : if(@cond 1 , @second, @color);
}
p {
padding : 50px 0px 0px 45px ;
color : @hex;
}
|
Syntax: To compile the above LESS code to CSS code, run the following command.
lessc styles.less styles.css
style.css: The CSS output of the above Less file was compiled.
style.css
body {
background-color : #eeeeee ;
}
.c 1 {
width : 250px ;
height : 150px ;
margin : 1 rem;
background-color : #3a150b ;
}
p {
padding : 50px 0px 0px 45px ;
color : hsla( 90 , 100% , 50% , 0.85 );
}
|
Output:
Reference: https://lesscss.org/functions/#color-operations-fadein
Similar Reads
Less.js Color Operation fade() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. Because CSS uses a dynamic style sheet language, it is more advantageous. LESS is adaptable enough to function in a variety of browsers. A computer language called
3 min read
Less.js Color Operation fadeout() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. Since CSS uses a dynamic style sheet language, it is superior. LESS is adaptable enough to function in a variety of browsers. A computer language called the CSS pr
3 min read
Less.js Color Operation darken() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. It is more advantageous because CSS employs a dynamic style sheet language. Several different browsers can use LESS because of its flexibility. In order for web br
3 min read
Less.js Color Operation Functions
Less (Leaner Style Sheets) is an extension to normal CSS which basically enhances the abilities of normal CSS and gives it superpowers. Color operation functions are built in Less.js to perform various operations such as saturation, de-saturation, lighten, darken, etc on a color object and return th
8 min read
Less.js Color Operation contrast() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. It is better since CSS makes use of a dynamic style sheet language. LESS is flexible enough to work in a wide range of browsers. To create and improve CSS so that
3 min read
Less.js Color Operation mix() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. Since CSS uses a dynamic style sheet language, it is superior. LESS is adaptable enough to function in a variety of browsers. In order for web browsers to use CSS,
4 min read
Less.js Color Operation desaturate() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. CSS is more beneficial because it makes use of a dynamic style sheet language. LESS is flexible enough to work in a wide range of browsers. The CSS pre-processor i
3 min read
Less.js Color Operation tint() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. CSS is better since it makes use of a dynamic style sheet language. LESS is flexible enough to work in a wide range of browsers. CSS must be created and developed
3 min read
Less.js Color Operation spin() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. CSS is better since it makes use of a dynamic style sheet language. LESS is flexible enough to work in a wide range of browsers. CSS is created and improved using
3 min read
Less.js Color Operation shade() Function
Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. Since CSS uses a dynamic style sheet language, it is superior. LESS is adaptable enough to function in a variety of browsers. Web browsers can only use CSS if it i
3 min read