为 html 制作一个颜色可变的图像?
Make a color changeable image for html?
所以我想知道使 PNG 图像变色的最佳方法。
我在 Photoshop 上有它,它应该在我的网站上有很多不同的颜色,我不想经历将它保存在所有颜色中的麻烦。
有更简单的方法吗?喜欢创建字体?保存为html可以改变颜色的格式?
提前致谢
将您的 PNG 转换为 SVG(有像这样的在线转换器 http://image.online-convert.com/convert-to-svg) and then manage it's color with a 'stroke' and 'fill' properties. It's impossible to change color of a binary file (which a PNG file is) using CSS. If this option is not acceptable then make a sprite (https://css-tricks.com/css-sprites/)。
查看 CSS 过滤器 属性:https://developer.mozilla.org/en-US/docs/Web/CSS/filter
我想你想要的是hue-rotate()
。
这是针对 IE 的:https://msdn.microsoft.com/en-us/library/dn858632(v=vs.85).aspx
示例:
/* CSS */
img {
-webkit-filter: hue-rotate(90deg);
filter: hue-rotate(90deg);
}
所以我想知道使 PNG 图像变色的最佳方法。 我在 Photoshop 上有它,它应该在我的网站上有很多不同的颜色,我不想经历将它保存在所有颜色中的麻烦。
有更简单的方法吗?喜欢创建字体?保存为html可以改变颜色的格式?
提前致谢
将您的 PNG 转换为 SVG(有像这样的在线转换器 http://image.online-convert.com/convert-to-svg) and then manage it's color with a 'stroke' and 'fill' properties. It's impossible to change color of a binary file (which a PNG file is) using CSS. If this option is not acceptable then make a sprite (https://css-tricks.com/css-sprites/)。
查看 CSS 过滤器 属性:https://developer.mozilla.org/en-US/docs/Web/CSS/filter
我想你想要的是hue-rotate()
。
这是针对 IE 的:https://msdn.microsoft.com/en-us/library/dn858632(v=vs.85).aspx
示例:
/* CSS */
img {
-webkit-filter: hue-rotate(90deg);
filter: hue-rotate(90deg);
}