简体   繁体   English

有没有办法制作打孔的文字?

[英]Is there a way to make a perfored text?

I'd like to put a background image on a div, and place a perfored text over it (ie the border of the perfored text will be white). 我想在div上放置一个背景图片,并在其上放置一个穿孔的文本(即,穿孔文本的边框将是白色的)。

So I can see the image only across the text. 因此,我只能在文本上看到图像。

Since my text is dynamic (can't make .PNG of every word) is there a way to do this in jquery/css? 由于我的文本是动态的(不能对每个单词都使用.PNG格式),有没有办法在jquery / css中做到这一点? Or the only solution is SVG/Canvas? 还是唯一的解决方案是SVG /画布?

Where could I start to do such a task? 我可以从哪里开始做这样的任务? It must be cross-browser (at least) for some major release (I don't mind of IE7 for example). 对于某些主要版本,它必须是跨浏览器的(至少)(例如,我不介意IE7)。

-webkit-text-fill-color works only on chrome... -webkit-text-fill-color仅适用于chrome ...

Are you trying to achieve something like this? 您是否正在尝试实现这样的目标?

 h1 { color: white; /* Fallback: assume this color ON TOP of image */ background: url("http://lorempixel.com/400/400") no-repeat; -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-family: Impact; } .backgroundclip h1 { background: url("http://lorempixel.com/400/400") 0 0 no-repeat; -webkit-background-clip: text; -webkit-text-fill-color: transparent; } h1 { color: orangered; text-shadow: 0px 0px 2px 2px #fff; } .android .gradient-text { color: white; background: none; -webkit-text-fill-color: white; -webkit-background-clip: border-box; } .gradient-text { background: -webkit-linear-gradient(gray, black); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } 
 <h1>Hey Dude</h1> 

Something like this? 像这样吗 The fill none, stroke white gives you the white border and the clipped image, the background. 没有填充,描边白色为您提供白色边框和裁剪后的图像,即背景。

 <svg width="100%" height="100%" viewBox="0 0 480 360"> <defs> <clipPath id="sample" clipPathUnits="userSpaceOnUse"> <text x="45" y="120" font-size="100">Clip Test</text> </clipPath> </defs> <rect width="100%" height="100%" fill="black">Clip Test</rect> <image xlink:href="http://www.w3.org/Graphics/SVG/Test/20110816/images/bluesquidj.png" preserveAspectRatio="none" x="20" y="20" width="410" height="160" clip-path="url(#sample)"/> <text x="45" y="120" font-size="100" fill="none" stroke="white" stroke-width="2">Clip Test</text> </svg> 

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

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