javascript - CSS Background color fill for the Icons - Stack Overflow

I am planning to use flag image for the status. Please see the imageIn this image i want to fill the ba

I am planning to use flag image for the status. Please see the image

In this image i want to fill the background color of the flag using CSS. The background color code is ing from server then i want to update the flag's color according to the color i got from server

I tried with SVG but it is not working in IE8. Please help me how to do this. thanks in advance for any help

Note: I need to support From IE7 to latest browsers. Don't want to use separate images for different colors.

I am planning to use flag image for the status. Please see the image

In this image i want to fill the background color of the flag using CSS. The background color code is ing from server then i want to update the flag's color according to the color i got from server

I tried with SVG but it is not working in IE8. Please help me how to do this. thanks in advance for any help

Note: I need to support From IE7 to latest browsers. Don't want to use separate images for different colors.

Share Improve this question asked Jul 31, 2013 at 14:25 Mohamed HussainMohamed Hussain 7,72315 gold badges60 silver badges87 bronze badges 4
  • Why can't you use an image and swap it out? I would think that would be easier. – Keith Commented Jul 31, 2013 at 14:26
  • 1 @Keith well if the number of colors that need to be supported is large, that would be a problem. – Pointy Commented Jul 31, 2013 at 14:26
  • I feel like you either want to use images here, or a rectangular flag. Otherwise this is going to be ugly - and probably wont ever work in older versions of IE. – Gray Commented Jul 31, 2013 at 14:28
  • 1 You shouldn't be supporting IE7. It's been discontinued and usage has fallen below 1% – jezzipin Commented Jul 31, 2013 at 14:38
Add a ment  | 

3 Answers 3

Reset to default 4

You can use the Font Awesome Icon library to draw the flag as an font and change the color with css.

http://fortawesome.github.io/Font-Awesome/icons/

<i class="icon-flag" style="color: green"></i>
<i class="icon-flag" style="color: orange"></i>
<i class="icon-flag" style="color: red"></i>

example http://jsfiddle/QvQtg/1/

If your flag will always be on the same background-color, you can simply use a .png, cut a hole where your color should appear and use background-color and background-image to create the desired result.

Html

<div class="flag"></div>

CSS

.flag {
    width: 45px;
    height: 54px;
    background-color: #f00;
    background-image: url(http://i.imgur./dD84kjR.png);
}

Example on JsFiddle: http://jsfiddle/a4EZ9/

For font-awesome version 5 Pro, you can just set font-wight to 900 and it will fill the icon.

content: "\f058";
font-family: "Font Awesome 5 Pro";
font-style: normal;
font-weight: 900;
font-size: 20px;
color: green;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745389607a4625600.html

相关推荐

  • javascript - CSS Background color fill for the Icons - Stack Overflow

    I am planning to use flag image for the status. Please see the imageIn this image i want to fill the ba

    10小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信