您当前的位置: 首页 >  css

彭世瑜

暂无认证

  • 1浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

彭世瑜 发布时间:2021-02-19 11:03:54 ,浏览量:1

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

Node.js使用代码实例

// 引入工具和插件
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);
}
*/

关注
打赏
1665367115
查看更多评论
立即登录/注册

微信扫码登录

0.0557s