css3 - Colour overlay for SVG using CSS? -
is there way apply colour overlay svg using css?
i have svgs (icons, shapes etc) need able "tint" - adding solid colour overlay keep transparency.
i read css filters, none of them cater adding colour on top, stuff blur or desaturate.
please check code snippet. hope you.
<svg width="0" height="0" class="svg-visiblity"> <defs> <path id="hex" d="m11.5,20.9l44.3,2c3.7-2.2,8.3-2.2,12.1,0l32.8,18.9c3.7,2.2,6,6.1,6,10.4v37.8c0,4.3-2.3,8.3-6,10.4 l56.3,98.4c-3.7,2.2-8.3,2.2-12.1,0l11.5,79.5c-3.7-2.2-6-6.1-6-10.4v31.3c5.4,27,7.7,23,11.5,20.9z"/> <clippath id="hex-clip-200"> <use xlink:href="#hex" transform="scale(2 2)" /> </clippath> </defs> </svg> <svg class="image-200-2"> <rect class="border" width="100%" height="100%" transform="scale(1.02)" style="clip-path: url(#hex-clip-200);" /></rect> <image xlink:href="http://placehold.it/200x200" width="200" height="200" transform="translate(2 2)" style="clip-path: url(#hex-clip-200);"></image> </svg>
css
.image-200-2 { display: inline-block; height: 205px; width: 205px; } .image-200-2 .border { fill: rgba(0, 0, 0, 0.5); } .svg-visiblity { height: 0; opacity: 0; position: absolute; width: 0; }
see here: https://jsfiddle.net/zyr8wovg/4/
Comments
Post a Comment