admin管理员组文章数量:1431037
I wish to mask some anchor text of size 4.5em with a repeating image, so that the image would only show over the region where text is present. Is there any way that I can do this with CSS? Please help with relevant code and example, if possible. Thanks. :)
I wish to mask some anchor text of size 4.5em with a repeating image, so that the image would only show over the region where text is present. Is there any way that I can do this with CSS? Please help with relevant code and example, if possible. Thanks. :)
Share Improve this question asked Sep 6, 2011 at 7:20 ikartik90ikartik90 2,8256 gold badges28 silver badges38 bronze badges 2- 2 Ask for ideas not the code. Also show us what you have done so far. – Mahesh Commented Sep 6, 2011 at 7:23
- @mahesh: I didn't mean the exact code. I meant something like an example brother. – ikartik90 Commented Sep 6, 2011 at 9:26
2 Answers
Reset to default 3I think you're not out of luck! The only fathomable way to do this in CSS is using the image-mask property. It's really easy, but it has pretty poor browser support at the moment. think it works well in firefox, opera and google chrome. No IE support at the moment. Here's how it's used:
p{
-webkit-mask-image: url(/path/to/mask.png);
-o-mask-image: url(/path/to/mask.png);
-moz-mask-image: url(/path/to/mask.png);
mask-image: url(/path/to/mask.png);
}
That will mask every paragraph with the image path. Fortunately, it degrades nicely in IE, so users won't even notice anything wrong it'll show up as normal text! so if you don't REALLY need IE support, do this. If you do need IE support:
Use an image. Make it in photoshop. :(
Here's a demo of how its used:
http://trentwalton./2011/05/19/mask-image-text/
They are not liking the mask-image
property outside WebKit but at the moment you can simulate it via "filter" in IE and via SVG in Firefox(/Opera?/WebKit?/IE?)
本文标签: javascriptApply image mask over text using CSSStack Overflow
版权声明:本文标题:javascript - Apply image mask over text using CSS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745464252a2659462.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论