Using :extend pseudo-class with multiply parameters in LESS file

The last topic about LESS explains how use :extend psedudo-class for extend one class in CSS. In this post you will find out how extend one class about rules form several others classes. Look at our less file:

.first {
    color: orangered;
}
.second {
    font-variant: small-caps;
}
.extProp {
    &:extend(.first, .second);
    background-color: yellowgreen;
}

and see CSS file after compiled LESS file:

.first, .extProp {
  color: orangered;
}
.second, .extProp {
  font-variant: small-caps;
}
.extProp {
  background-color: yellowgreen;
}

And it is our HTML file:

<!DOCTYPE html>
<html>
    <head>
        <title>Animals</title>
        <link rel="stylesheet" href="myStyle.css"  type="text/css" >
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <h1>My favorite animals</h1>
        <h3 class='first'>Pets</h3>
        <div><p class='second'>Dogs</p></div>
        <div><p class='extProp'>Hamsters</p></div>
        <p>and others animals</p>
    </body>
</html>

The effect run website:
As you notice, the paragraph is formated by extParam class so has red color from first class and small-capitalics from second class and green background color from extParam class. The rules from first and second classes are inherited thanks :extends pseudoclass.

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.