Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
The 'less' npm package is a pre-processor for CSS, which extends the capabilities of CSS with dynamic behavior such as variables, mixins, operations, and functions. It allows developers to write CSS in a more maintainable and extendable way.
Variables
Variables allow you to specify widely used values in a single place, and then reuse them throughout the stylesheet, making your CSS more maintainable.
@primary-color: #4D9FEC;
a {
color: @primary-color;
}
Mixins
Mixins allow you to embed all the properties of a class into another class by simply including the class name as one of its properties. It's like variables, but for whole classes.
.bordered {
border-top: dotted 1px black;
border-bottom: solid 2px black;
}
#menu a {
.bordered;
}
Nested Rules
Nested rules make it possible to nest selectors inside other selectors. This makes the structure of your CSS mirror the structure of your HTML.
#header {
color: black;
.navigation {
font-size: 12px;
}
.logo {
width: 300px;
}
}
Functions & Operations
Functions and operations let you manipulate numbers and colors, doing math with them and applying functions to achieve dynamic results.
@base: 5%;
.padding {
padding: @base * 2;
}
Sass (Syntactically Awesome Stylesheets) is a mature, stable, and powerful professional grade CSS extension language. It provides similar features to Less, such as variables, mixins, and nested rules. Sass has two syntaxes: the original 'indent' syntax that is similar to Haml and the newer 'SCSS' that uses braces like CSS. It's one of the most popular CSS preprocessors.
Stylus is a preprocessor that offers a mix of features from both Sass and Less, as well as some additional unique features. It has a more flexible syntax that can be written with or without braces, colons, and semicolons. Stylus provides powerful and efficient stylesheet writing capabilities.
PostCSS is a tool for transforming CSS with JavaScript plugins. These plugins can lint your CSS, support variables and mixins, transpile future CSS syntax, inline images, and more. PostCSS is different from preprocessors like Sass and Less in that it's modular and can be configured to perform a wide variety of tasks.
less.js is the next evolution of LESS, eventually, it will become LESS 2.0. less.js is a complete rewrite of LESS in JavaScript, and will be able to run directly in the browser, as well as on the server, with node.js.
Go to the Downloads section, and get the latest version:
http://github.com/cloudhead/less.js/downloads
var less = require('less');
less.render(".class { width: 10px * 2 }", function (e, css) {
sys.puts(css); // .class { width: 20px }
});
bin/lessc style.less
First, run make less
in the command line. It will the build the less.js file in dist/.
Then, you can use it as such:
<link rel="stylesheet/less" href="main.less" type="text/css">
<script src="less.js"></script>
To build a minified version, run make min
In node:
$ npm install less
FAQs
Leaner CSS
The npm package less receives a total of 5,023,553 weekly downloads. As such, less popularity was classified as popular.
We found that less demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.