evrone / postcss-px-to-viewport

A plugin for PostCSS that generates viewport units (vw, vh, vmin, vmax) from pixel units. The best choice to create a scalable interface on different displays by one design size.
https://evrone.com/postcss-px-viewport
MIT License
2.99k stars 401 forks source link

在js中动态设置样式无效 #105

Open w745784780 opened 2 years ago

w745784780 commented 2 years ago

在js中动态设置样式无效,行内标签中设置样式无效

ace0109 commented 2 years ago

@w745784780 动态设置的无效,要自己算。1vw = 3.75px,自己算一下自己要多少px,换算成vw。

w745784780 commented 2 years ago

@w745784780动态设置的无效,要自己算。1vw = 3.75px,自己算一下自己要多少px,换算成vw。

意思是根据屏幕大小来计算元素宽高

LuoRiWuSheng commented 1 year ago

是这么个意思, 你js里面动态设置的css单位还是 px 这不是响应式的, 你期望是 js 设置 10px --》 转换成对应的 vw 是需要你自己拿到对应比例, 得出 1px --> 转成多少vw 才可以

vw是 屏幕宽度的 1% 这种情况,你只能自己算

vaynevayne commented 1 year ago

有没有办法可以把react的行内样式抽离到单独的css文件?