Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@csstools/postcss-sign-functions
Advanced tools
npm install @csstools/postcss-sign-functions --save-dev
PostCSS Sign Functions lets you use the sign
and abs
functions, following the CSS Values 4 specification.
.sign {
z-index: sign(-10px);
}
.sign {
z-index: sign(0);
}
.sign {
z-index: sign(10px);
}
.abs {
z-index: abs(-10px);
}
.abs {
z-index: abs(0);
}
.abs {
z-index: abs(10px);
}
.abs {
z-index: abs(10%);
}
/* becomes */
.sign {
z-index: -1;
}
.sign {
z-index: 0;
}
.sign {
z-index: 1;
}
.abs {
z-index: 10px;
}
.abs {
z-index: 0;
}
.abs {
z-index: 10px;
}
.abs {
z-index: max((10%), -1 * (10%));
}
[!NOTE] The utility of static fallbacks for
sign
andabs
is limited. The most interesting values are variables and dynamic values (e.g. those containing%
). It is impossible to generate static fallbacks in a build process for values that are dynamic on the client.
Add PostCSS Sign Functions to your project:
npm install postcss @csstools/postcss-sign-functions --save-dev
Use it as a PostCSS plugin:
const postcss = require('postcss');
const postcssSignFunctions = require('@csstools/postcss-sign-functions');
postcss([
postcssSignFunctions(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
Given the dynamic nature of custom properties it's impossible to know what the variable value is, which means the plugin can't compute a final value for the stylesheet.
Because of that, any usage that contains a var
is skipped.
The preserve
option determines whether the original notation
is preserved. By default, it is not preserved.
postcssSignFunctions({ preserve: true })
.sign {
z-index: sign(-10px);
}
.sign {
z-index: sign(0);
}
.sign {
z-index: sign(10px);
}
.abs {
z-index: abs(-10px);
}
.abs {
z-index: abs(0);
}
.abs {
z-index: abs(10px);
}
.abs {
z-index: abs(10%);
}
/* becomes */
.sign {
z-index: -1;
z-index: sign(-10px);
}
.sign {
z-index: 0;
z-index: sign(0);
}
.sign {
z-index: 1;
z-index: sign(10px);
}
.abs {
z-index: 10px;
z-index: abs(-10px);
}
.abs {
z-index: 0;
z-index: abs(0);
}
.abs {
z-index: 10px;
z-index: abs(10px);
}
.abs {
z-index: max((10%), -1 * (10%));
z-index: abs(10%);
}
FAQs
Use sign and abs functions in CSS
The npm package @csstools/postcss-sign-functions receives a total of 85,395 weekly downloads. As such, @csstools/postcss-sign-functions popularity was classified as popular.
We found that @csstools/postcss-sign-functions demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.