Skip to content

How to place rem to vw #2950

Answered by asd8855
ShaneLee-9 asked this question in Q&A
Aug 5, 2023 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Try it
// uno.config.ts
postprocess: [
(util) => {
// implement postcss-pxtorem
const pxRE = /(-?[.\d]+)px/g;
util.entries.forEach((entry) => {
const value = entry[1];
if (typeof value === 'string' && pxRE.test(value)) {
// 100 is [rootValue] of postcss-pxtorem in my project
// eslint-disable-next-line no-param-reassign
entry[1] = value.replace(pxRE, (_, pixelValue) => ${pixelValue / 100}vw);
}
});
}
]

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@ShaneLee-9
Comment options

@asd8855
Comment options

Answer selected by ShaneLee-9
@asd8855
Comment options

@ShaneLee-9
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants