I am using the following implementation to mask an element using an SVG and some CSS.
//styles.css
.elementToBeMasked {
width: 100%;
height: 100%;
position: absolute;
z-index: 1;
display: block;
overflow: hidden;
clip-path:url(rhombus.svg#rhombusclip);
-webkit-mask:url(rhombus.svg#rhombus);
-webkit-mask-repeat:no-repeat;
} ...
//rhombus.svg
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="500" height="500">
<clipPath id="rhombusclip">
<path id="rhombuspath" d="M0,0 L500,0 500,500 100,500 z" fill="#000000" />
</clipPath>
<path id="rhombus" d="M0,0 L500,0 500,500 100,500 z" fill="#000000" />
</svg>
This works fine across Chrome, Safari and Firefox. However, I'm hoping to animate some of the properties, and so I've been trying to bring the SVG inline into my HTML.
This is my inline SVG code:
//index.html
<div class="elementToBeMasked">...</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="500" height="500">
<clipPath id="rhombusclip">
<path id="rhombuspath" d="M0,0 L500,0 500,500 100,500 z" fill="#000000" />
</clipPath>
<path id="rhombus" d="M0,0 L500,0 500,500 100,500 z" fill="#000000" />
</svg>
And this is my updated CSS:
//styles.css
.elementToBeMasked {
...
clip-path:url(index.html#rhombusclip);
-webkit-mask:url(index.html#rhombus);
}
This implementation doesn't work across any browser. Any suggestions would be greatly appreciated.