CSS video of text with transparent background not working on safari - css

So i am trying to make a heading text animated with a background video playing within the letters. The code below is my solution which works perfectly on all browsers except safari. Im aware that safari only partially supports clip-path which is probably where the problem lies. I have been wrecking my head trying to think of a solution and need some ideas. Can the code below be altered to make it work on safari or is there perhaps another approach I can take to achieve the same outcome.
An example of what I am trying to achieve can be seen here https://levelup.gitconnected.com/animate-svg-text-with-a-video-background-bf1d03e47600
Scroll down to the life's a beach text with the video in the background.
Help is much appreciated!
<svg>
<defs>
<clipPath id="clip-00" clipPathUnits="objectBoundingBox" transform="scale(0.0013208333333333333, 0.002225925925925926)">
<path d="M741.58,421.68V373H613.37V313h71.39V264.7H613.37v-43H736.26V173.06H563.65V421.68Zm-206.13,0V173.06h-49V278.19c0,13.85.71,45.11.71,54.34-3.2-6.39-11.37-18.82-17.4-28.06L381.67,173.06h-47.6V421.68h49V312.29c0-13.85-.71-45.11-.71-54.34,3.19,6.39,11.36,18.82,17.4,28.06l91.28,135.67ZM267.31,297.73c0,50.43-23.09,78.49-57.9,78.49s-58.95-28.77-58.95-79.2,23.08-78.5,57.89-78.5,59,28.77,59,79.21m51.14-.71c0-80.27-44.4-127.86-109-127.86-65,0-110.1,48.3-110.1,128.57s44.4,127.85,109.39,127.85c64.64,0,109.75-48.3,109.75-128.56" />
<path d="M486.4,278.2c0,13.9,0.7,45.1,0.7,54.3c-3.2-6.4-11.4-18.8-17.4-28.1l-88.1-131.4h-47.6v248.6h49V312.3
c0-13.9-0.7-45.1-0.7-54.3c3.2,6.4,11.4,18.8,17.4,28.1l91.3,135.7h44.4V173.1h-49V278.2z" />
</clipPath>
</defs>
</svg>
<div class="video-container">
<video loop autoplay muted playsinline>
<source src="#" type="video/mp4">
<source src="#" type="video/webm">
<img src="#">
</video>
</div>
In my css file I have this -
video {
-webkit-clip-path: url(#clip-00);
clip-path: url(#clip-00);

Related

css clip-path with svg not working in Chrome

I've created an svg for use as a clip-path on an image, and it appears perfect in Firefox, however it doesn't work in Chrome, and I'm wondering what the problem is.
Chrome should support an inline svg clip-path according to this.
And full support according to MDN.
<style>
img {
width: 40%;
height: auto;
display: inline;
}
.clip {
-webkit-clip-path: url('#clip');
clip-path: url('#clip');
}
</style>
<p>Left image should be clipped, right image is not.</p>
<img src="https://i.imgur.com/nnHdzO6l.jpg" class="clip">
<img src="https://i.imgur.com/nnHdzO6l.jpg" >
<svg version="1.1"
baseProfile="full"
height="400" width="400"
xmlns="http://www.w3.org/2000/svg">
<defs>
<clipPath id="clip"
clipPathUnits="objectBoundingBox"
transform="scale(0.0025, 0.0025)">
<!-- https://css-tricks.com/scaling-svg-clipping-paths-css-use/ -->
<circle cx="50%" cy="50%" r="50%" />
<rect width="82.8%" height="82.8%" y="17.2%" x="8.6%" />
</clipPath>
</defs>
</svg>
External SVG files are not supported by Chrome at the moment.
You can check this here:
https://caniuse.com/#search=CSS%20clip
Here is what they say about the Partial support for Chrome:
Partial support refers to supporting shapes and the url(#foo) syntax
for inline SVG, but not shapes in external SVGs.

How to make overflow-ed SVG content viewable via scrolling?

I have this simple HTML:
<html>
<body>
<embed src="test.svg" type="image/svg+xml" style="border:3px solid green;width:200px;height:200px;overflow:scroll;">
</body>
</html>
And a simple SVG:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" style="border:3px solid red;width:500px;height:500px;overflow:auto;">
<circle cx="50" cy="250" r="80" stroke="green" stroke-width="4" fill="yellow" />
</svg>
The output from browsers:
[1,1] Edge: OK
[2,1] IE11: OK
[1,2] Chrome55: Not scrollable
[2,2] Firefox50: Scrollable at a negligible degree
How to ensure Firefox and Chrome able to have scrollable <embed> with overflow-ed SVG content, as in Edge and IE?
Thank you.
just put a div around the embed und use that as scrolling area...
<html>
<body>
<div style="border:3px solid green;width:100px;height:100px;overflow:scroll;">
<embed src="https://upload.wikimedia.org/wikipedia/commons/e/e9/SVG-Grundelemente.svg" type="image/svg+xml">
</div>
</body>
</html>
to match the behaviour of MS browsers, you have to extend your viewBox to contain all elements you want to be able to scroll to...
given the appropiate width and height should do want you want then...
You can as well roll your own zoom and pan solution using svgDocuments currentTranslate and currentScale properties... I would be curious how currentTranslate behaves for this weird MS behaviour...

Custom CSS shape with borders and background image

Hi guys im trying to do this in css/sass only! The border have to change on rollover and the background could be an image! I tried SVG and clipPath, transform3d without any success!Example here
Create the container div and use transforms in CSS to give the entire element the 3d effect. You can look this up and play with the values to your liking.
Make the background image the background of the container div to keep it simple.
Use an SVG to draw the controller icon. There are some tutorials out there on how to export a path for an SVG using GIMP, at least that is what I do for complicated shapes like this.
Ok, this is best done like this, first the html structure:
<div id="imageContainer" class="center">
<h2>Lets go and see how it goes</h2>
<img class="pic" src="https://moltopiccolo.files.wordpress.com/2012/01/cool- drinks.jpg">
</div>
This means, you have a container div and place your img in that container, it is important to not have the img as div background in this instance.
Second, position the div relative, the image absolute.This will only work if the image is positioned absolute.
Now declare a clip path, there are generators for different shapes with previews etc, check the codepen for the correct declarations.
Give a transition to the clip path, make sure to use the prefixes.
Now it is up to you wheter you want to trigger the animation on hover, this can be done with css. If you want the animations triggered on click, you can do that in JS and change the clip paths with JS.
I think the border animation needs no explanation, this is the very easiest part, if you need help with that, let me know.
Here is the link, hover over the picture and see:-)
http://codepen.io/damianocel/pen/KdobyK
There is the workaround that we found. It will need some adjustement but look good for our need!
<a href="">
<svg class="stroke-path" height="100%" width="100%">
<defs>
<pattern id="img1" patternUnits="userSpaceOnUse" width="100%" height="100%">
<image xlink:href="http://cdn.collider.com/wp-content/uploads/super-mario-bros.jpg" x="0" y="0" width="100%" height="100%" />
</pattern>
</defs>
<path id="mlp2" d="M206.5,173.1L33.3,162.5c-6.3,0-11.4-5.1-11.3-11.4c0,0,0,0,0,0L10.5,39.8c0-6.3,5.1-11.4,11.3-11.4 c0,0,0,0,0,0l208.2-17.9c6.3,0,11.4,5.1,11.3,11.4c0,0,0,0,0,0l-23.6,139.8C217.8,168,212.8,173.1,206.5,173.1 C206.5,173.1,206.5,173.1,206.5,173.1z" fill="url(#img1)" fill-opacity="1" />
</svg>
<svg class="" height="100%" width="100%">
<defs>
<filter id="f1" x="0" y="0" width="200%" height="200%">
<feOffset result="offOut" in="SourceGraphic" dx="0" dy="0" />
<feGaussianBlur result="blurOut" in="offOut" stdDeviation="8" />
-->
http://codepen.io/anon/pen/vXBPOz

is there any way to use an svg (img) to crop an image?

As far as I understand (by reading previously posted questions on stackoverflow) that cropping an image using svg coorindates is possible, but it is possible to crop an image by using an svg link? for example: <img src="http://imgh.us/face01.svg">
EDIT: This is what I meant:
Thanks!
Yes. You can do it using the mask-image property. This is supported on all browsers except IE.
.masked {
-webkit-mask-image: url(http://imgh.us/face01.svg);
mask-image: url(http://imgh.us/face01.svg);
}
<img src="http://lorempixel.com/400/400" width="400" height="400" class="masked">
Unfortunately you will still need to make other arrangements for IE.
You can do it all inside SVG using the image element combined with a SVG mask or a SVG filter and have it work on IE10+ (and all other browsers). Here is the filter example:
<svg width="400px" height="400px">
<defs>
<filter id="crop-me" x="0%" y="0%">
<feImage xlink:href="http://imgh.us/face01.svg" result="area"/>
<feComposite operator="in" in="SourceGraphic" in2="area"/>
</filter>
</defs>
<image filter="url(#crop-me)" xlink:href="http://lorempixel.com/400/400" x="0" y="0" width="200" height="300"/>
</svg>

Clip-path using inline SVG clipping wrong elements when position:absolute

This is a little hard to explain, so here's a jsFiddle to show what I mean.
<style>
.clip {
clip-path: url(#clippath);
-o-clip-path: url(#clippath);
-moz-clip-path: url(#clippath);
-webkit-clip-path: url(#clippath);
}
</style>
<div id="container">
<svg>
<defs>
<clippath id="clippath">
<rect x="0" y="0" width="50" height="320" />
</clippath>
</defs>
</svg>
<div id="d1">Bottom</div>
<div id="d2" class="clip">Middle</div>
<div id="d3">Top</div>
</div>
The problem is that I want to apply a clip-path to an absolutely positioned element, however I am finding that all other absolutely positioned elements which appear after it in the DOM will be clipped too. This isn't the case with relatively positioned elements, oddly.
How can I make sure that only the desired element is clipped? I can't see anything wrong with my code. Is this a bug?
This now behaves correctly in all browsers I've tested aside from Internet Explorer (which lacks support for clippath on HTML elements entirely), and as such it's no longer a problem.

Resources