I’m using a SVG sprite like this in the body:
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="bars" width="1792" height="1792" viewBox="0 0 1792 1792">
<path d="M1664 1344v128q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45zm0-512v128q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45zm0-512v128q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45z"/>
</symbol>
</svg>
If I need the symbol, I call it like this:
<svg class="icon left bars" style="fill: #000;">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#bars"></use>
</svg>
Now I need this SVG in a CSS ::after
. I know that you can use a SVG as background image in the ::after
but it won’t work with use:
.element::after {
background: url('data:image/svg+xml;utf8,<svg class="icon left bars" style="fill: #000;"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#bars"></use></svg>') no-repeat;
//background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='61' height='41' fill='#000' stroke='none'><path d='M0,0 6,10 L12,0 L0,0 Z'></path></svg>") no-repeat;
content: "";
display: block;
height: 16px;
width: 16px;
}
Demo: JSFiddle
Is there anyone who got this working?