JS:样式转换工具PostCSS使用浏览器前缀插件autoprefixer

网友投稿 740 2022-05-30

PostCSS 是一个允许使用 JS 插件转换样式的【工具】

autoprefixer 添加了 vendor 浏览器前缀的【插件】

PostCSS 文档:https://github.com/postcss/postcss/blob/main/docs/README-cn.md

PostCSS Github: https://github.com/postcss/postcss

安装

npm i postcss autoprefixer

1

Node.js使用代码实例

JS:样式转换工具PostCSS使用浏览器前缀插件autoprefixer

// 引入工具和插件 const Postcss = require("postcss"); const Autoprefixer = require("autoprefixer"); // 设置插件 const processor = Postcss([Autoprefixer]); // 处理css const css = ` .box{ transform: scale(0.5); } `; processor.process(css, { from: undefined }).then(result => { result.warnings().forEach(warn => { console.warn(warn.toString()); }); console.log(result.css); }); /* 输出: .box{ -webkit-transform: scale(0.5); transform: scale(0.5); } */

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

CSS PostCSS

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:spring-boot-plus后台快速开发脚手架之代码生成器使用
下一篇:nodejs学习笔记
相关文章