I have such a structure in HTML where I must put an icon, which is referred in an external URL, with an especific color. The color changes depending on the situation, and because of that, the icon shouldn't contain the color info.
To do that, I've been using a colored background and masking it with the external icon in SVG format, like this:
<style>
.icon-resource {
display: inline-block;
height: 24px;
width: 24px;
background-color: #35b6b6; /* example color */
mask: url(https://image.flaticon.com/icons/svg/684/684809.svg) no-repeat;
-webkit-mask: url(https://image.flaticon.com/icons/svg/684/684809.svg) no-repeat;
-webkit-mask-size: cover;
mask-size: cover;
}
</style>
<span class="icon-resource"></span>
Sadly, IE doesn't support masking, and all I get in such browser is a colored square.
So that's the deal: I'm looking for a way to get an icon from external URL (I'm currently trying with SVG, but I'm flexible to other image format) and apply a custom color to it, and it must work on IE10+, as well as in Chrome and Firefox.
I already tried:
<style>
.icon-new {
display: inline-block;
height: 24px;
width: 24px;
}
</style>
<svg class="icon-new" viewBox="0 0 24 24">
<use style="fill:#35b6b6" xlink:href="https://image.flaticon.com/icons/svg/684/684809.svg#Capa_1"></use>
</svg>
but it accuses me of
Unsafe attempt to load URL https://image.flaticon.com/icons/svg/684/684809.svg#Capa_1 from frame with URL XXX. Domains, protocols and ports must match.
Tried to solve it with the answers to "Unsafe attempt to load url svg", but nothing helped.
I guess I might most probably have to implement some JS to retrieve the SVG using AJAX request, but that would be damn troubling in my project...