Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
postcss-at2x
Advanced tools
Adds at-2x keyword to background and background-image declarations to add retina support for images.
Ported from rework-plugin-at2x
$ npm install postcss postcss-at2x --save-dev
const fs = require('fs');
const postcss = require('postcss');
const at2x = require('postcss-at2x');
const input = fs.readFileSync('input.css', 'utf8');
const output = postcss()
.use(at2x())
.process(input)
.then(result => console.log(result.css));
Adds at-2x
keyword to background
and background-image
declarations to add retina support for images.
Input
.multi {
background: url(http://example.com/image.png),
linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1)),
green,
url(/public/images/cool.png) at-2x;
}
Output
.multi {
background: url(http://example.com/image.png),
linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1)),
green,
url(/public/images/cool.png);
}
@media (min-device-pixel-ratio: 1.5), (min-resolution: 144dpi), (min-resolution: 1.5dppx) {
.multi {
background-image: url(http://example.com/image.png),
linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1)),
none,
url(/public/images/cool@2x.png);
}
}
identifier
(default: "@2x"
) stringChange the identifier added to retina images, for example file@2x.png
can be file-retina.png
.
detectImageSize
(default: false
) booleanObtains the image dimensions of the non-retina image automatically and applies them to the
background-size
property of the retina image.
skipMissingRetina
(default: false
) booleanIf the retina image cannot be found on the file system it will be skipped and not output into the result CSS.
resolveImagePath
functionGet resolved image path for detecting image size. By default, original url
value is resolved from current working directory (process.cwd()
).
Function receives two arguments: original url
value and PostCSS declaration source.
Output
.element {
background: url(img.jpg) no-repeat;
}
@media (min-device-pixel-ratio: 1.5), (min-resolution: 144dpi), (min-resolution: 1.5dppx) {
.element {
background: url(img@2x.jpg) no-repeat;
background-size: 540px 675px; /* Dimensions of img.jpg */
}
}
See PostCSS docs for examples for your environment.
FAQs
Adds at-2x keyword to background and background-image declarations to add retina support for images.
The npm package postcss-at2x receives a total of 125 weekly downloads. As such, postcss-at2x popularity was classified as not popular.
We found that postcss-at2x demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.