Note that there are some explanatory texts on larger screens.

plurals
  1. POClip-path/web-kit-mask works when SVG is seperate file, but not when inline
    primarykey
    data
    text
    <p>I am using the following implementation to mask an element using an SVG and some CSS. </p> <pre><code>//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 &lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; &lt;!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"&gt; &lt;svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="500" height="500"&gt; &lt;clipPath id="rhombusclip"&gt; &lt;path id="rhombuspath" d="M0,0 L500,0 500,500 100,500 z" fill="#000000" /&gt; &lt;/clipPath&gt; &lt;path id="rhombus" d="M0,0 L500,0 500,500 100,500 z" fill="#000000" /&gt; &lt;/svg&gt; </code></pre> <p>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.</p> <p>This is my inline SVG code:</p> <pre><code>//index.html &lt;div class="elementToBeMasked"&gt;...&lt;/div&gt; &lt;svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="500" height="500"&gt; &lt;clipPath id="rhombusclip"&gt; &lt;path id="rhombuspath" d="M0,0 L500,0 500,500 100,500 z" fill="#000000" /&gt; &lt;/clipPath&gt; &lt;path id="rhombus" d="M0,0 L500,0 500,500 100,500 z" fill="#000000" /&gt; &lt;/svg&gt; </code></pre> <p>And this is my updated CSS:</p> <pre><code> //styles.css .elementToBeMasked { ... clip-path:url(index.html#rhombusclip); -webkit-mask:url(index.html#rhombus); } </code></pre> <p><em>This</em> implementation doesn't work across any browser. Any suggestions would be greatly appreciated. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload