Заполнение иконки SVG и обводка не работает - PullRequest
0 голосов
/ 07 июня 2018

У меня есть простой SVG, который по умолчанию я хочу красный, затем при наведении измените его на синий.Но похоже, что это не работает, идеи почему?

#svg-icon {
  fill: red;
  stroke: red;
}

#svg-icon:hover {
  cursor: pointer;
  fill: #005aa0;
  stroke: #005aa0;
}
<svg id="svg-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="62" height="52" viewBox="0 0 62 52"> <image id="Vector_Smart_Object" data-name="Vector Smart Object" width="62" height="52" xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAA0CAMAAADlhHsQAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAB7FBMVEUAWqD///8AWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAAWqAA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/O5Hz5+kk23ij7z8xfPelwtX1O6LhglRvgUr5lljcmrxUGPl6gxTr6lfI/NGP+Oth+8bzLEh1FM/ImSLpch7nEmjjN/Shvg5Gfy8stlcOlk+c8zeGQxi0QyT5tsI/EVI3xF5CS+ms3Uk1mNp34PFH8dLJlLZlEsJIoTY9d+p2WNVSwkjJH3FsKQ2L/wP8QRMzw+E3P8BbYpj1WiE5bLAAAAAElFTkSuQmCC"> </image></svg>

1 Ответ

0 голосов
/ 07 июня 2018

Как указано в комментариях, это изображение base64 , а не SVG , поэтому fill или stroke не будут работать с этим.Но вы можете попробовать вместо fill и stroke, использовать mask-image, а затем изменить background-color при наведении на что-то вроде следующего примера:

<a href="javascript:void(0)">
        <div class="img-smiley">
        </div>
    </a>

CSS

.img-smiley 
{
  background-color: red;
    -webkit-mask-image: url("data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjgwcHgiIGhlaWdodD0iODBweCIgdmlld0JveD0iMzIgLTMyIDgwIDgwIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDMyIC0zMiA4MCA4MCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8ZyBpZD0iIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgyMi4wMDAwMDAsIDk3Mi4wMDAwMDApIj4NCgk8ZyBpZD0iQW5zd2VyIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwLjAwMDAwMCwgMTEyLjAwMDAwMCkiPg0KCQk8ZyBpZD0iR3JvdXAtMTAiPg0KCQkJPGcgaWQ9IlBhZ2UtMS1Db3B5IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgyNS4wMDAwMDAsIDIwLjAwMDAwMCkiPg0KC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zYzAsMC45LTAuNywxLjctMS43LDEuN2MtMC45LDAtMS43LTAuNy0xLjctMS43YzAtMi44LTIuMi01LTUtNQ0KCQkJCQlzLTUsMi4yLTUsNWMwLDAuOS0wLjcsMS43LTEuNywxLjdjLTAuOSwwLTEuNy0wLjctMS43LTEuN0MzMS43LTExMDcuMywzNS40LTExMTEsNDAtMTExMSBNMjUtMTEzNmMtMjIuMSwwLTQwLDE3LjktNDAsNDANCgkJCQkJczE3LjksNDAsNDAsNDBzNDAtMTcuOSw0MC00MFM0Ny4xLTExMzYsMjUtMTEzNiIvPg0KCQkJPC9nPg0KCQk8L2c+DQoJPC9nPg0KPC9nPg0KPC9zdmc+DQo=");

    height:80px;
    width:80px;
    display:block;  
}

.img-smiley:hover{
    background:green;
}
...