2013-02-15 637 views
0

是否可以仅使用CSS更改图像的颜色?使用css更改图像的颜色?

(我使用的是透明背景执行glyphicons,我需要不同的符号[不包括后台]颜色我的主题)

+0

看看 http://stackoverflow.com/questions/3430343/how-can-the-colors-of-an-image-be-changed-using-css3 – Ingo 2013-02-15 08:33:27

回答

0

号由于这些图像图标,你不能改变它们的颜色。您可以尝试使用这些http://www.entypo.com/。由于这些是字体,他们可以很容易地改变颜色。

1

您可以使用图像色调,但我不知道它是否会为您提供您所期望的效果:

基本上你换一个<figure>元素的<img/>周围,将样式应用到它:

/*HTML*/ 
<figure class="tint"> 
    <img src="icon.png" width="400" height="260"> 
</figure> 

/*CSS*/ 
.tint { 
    position: relative; 
    float: left; 
    cursor: pointer; 
} 

.tint:before { 
    content: ""; 
    display: block; 
    position: absolute; 
    top: 0; 
    bottom: 0; 
    left: 0; 
    right: 0; 
    background: rgba(0,255,255, 0.5); 
    -moz-transition: background .3s linear; 
    -webkit-transition: background .3s linear; 
    -ms-transition: background .3s linear; 
    -o-transition: background .3s linear; 
    transition: background .3s linear; 
} 

.tint:hover:before { 
    background: none; 
} 

查看link了解演示和完整代码示例。

在这个website你也可以查看一些不同的方法。

+0

。当然,这是只有当你使用''标签。否则,如果它是CSS的背景,我不知道如何改变它。 – NielsInc 2013-02-15 09:21:12

+0

谢谢,但是它的背景也是如此(我可以通过在父标签中加上'style =“background-color:red”)来获得。 – stackoverflowuser95 2013-02-15 12:18:45