简体   繁体   English

带有透明字母的SVG背景,以查看其他内容

[英]SVG background with transparent letters to see the other content

I need to have a video running, and of top of it a black div with opacity less than 1 but with some text transparent to allow the user to see the video behind, and also a button with the same effect. 我需要运行一个视频,最重要的是一个黑色的div,其不透明度小于1,但带有一些透明的文本以使用户可以看到后面的视频,以及一个具有相同效果的按钮。

This is a picture of what I am looking for: 这是我正在寻找的图片:

在此处输入图片说明

I manage to this in another release by using a png covering the video area, but now I need that button to have the same effect and I though about SVG, but I don't know if it is exactly true that I can use it or how. 在另一个版本中,我通过使用覆盖视频区域的png来解决这一问题,但是现在我需要该按钮具有相同的效果,尽管我对SVG也是如此,但是我不知道我可以使用它还是不知道怎么样。

Thanks 谢谢

Here is how I would do it using an SVG image overlaying the background. 这是我将使用覆盖背景的SVG图像执行的操作。

 .wrapper { position: relative; } .wrapper svg { position: absolute; left: 0; top: 0; } 
 <div class="wrapper"> <img src="http://lorempixel.com/640/480"/> <svg id="overlay" width="640" height="480" viewBox="0 0 640 480"> <defs> <mask id="mymask"> <rect width="100%" height="100%" fill="white"/> <text x="320" y="140" text-anchor="middle" font-size="40px" >Some transparent text</text> <text x="320" y="190" text-anchor="middle" font-size="40px" >has been placed here</text> <rect x="220" y="300" width="200" height="50" fill="black"/> <text x="320" y="335" text-anchor="middle" fill="white" font-size="30px">BUTTON</text> </mask> </defs> <rect fill="black" fill-opacity="0.7" width="100%" height="100%" mask="url(#mymask)"/> </svg> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM