Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using an external svg with clip-path in Firefox

I'm trying to work with clip-path in firefox.

I'm using the following CSS in an external file:

.featured_event_panel{
  background:url(../images/home/screen2.jpg) repeat;
  background-position:center 50%;
  -webkit-clip-path: polygon(0 100%,100% 100%,100% 0%,50% 10%, 0 0);
  clip-path: url('../images/ui/clippath.svg#diamond');
  width:100%;
  padding:100px 0 150px;
  position:relative;
}

This doesn't work. The only way I can get the clipping path to work in FF is if I put this CSS rule in the head of the document and the SVG in the document too. The SVG is below:

<svg>
  <defs>
   <clipPath id="diamond" clipPathUnits="objectBoundingBox">
      <polygon points="0 1, 1 1, 1 0, .5 .1, 0 0" />
    </clipPath>
  </defs>
</svg>

The path to the SVG is right relative to the stylesheet so I'm not sure what I'm doing wrong here.

Any ideas? Cheers!

EDIT: Example: http://jsfiddle.net/25VQD/

like image 984
BarryWalsh Avatar asked Jul 18 '14 11:07

BarryWalsh


People also ask

Can I use SVG clip-path?

Support for clip-path in SVG is supported in all browsers with basic SVG support.

What is SVG clipping path?

The <clipPath> SVG element defines a clipping path, to be used by the clip-path property. A clipping path restricts the region to which paint can be applied. Conceptually, parts of the drawing that lie outside of the region bounded by the clipping path are not drawn.

How do you clip a path?

Hold down shift while selecting a preset to only update animation-preview clip-path. Hover to see animation between original state and current state. Animation will only work if the number of points are the same. This Pen is owned by Mads Stoumann on CodePen.


1 Answers

Your clip path is not a valid SVG file. The clue is that when you display it directly in Firefox it says "This XML file does not appear to have any style information associated with it. The document tree is shown below."

To fix it you'd need to add the SVG namespace to the root element i.e.

<svg xmlns="http://www.w3.org/2000/svg">
like image 197
Robert Longson Avatar answered Oct 20 '22 09:10

Robert Longson