16进制转rgba

function hexToRgba(hex, opacity) {
return “rgba(” + parseInt(“0x” + hex.slice(1, 3)) + “,” + parseInt(“0x” + hex.slice(3, 5)) + “,” + parseInt(“0x” + hex.slice(5, 7)) + “,” + opacity + “)”;
}
使用方法
hexToRgba(‘#00c154’, 0.2)

    原文作者:breathfish
    原文地址: https://segmentfault.com/a/1190000019683249
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞