简体   繁体   English

在可点击的链接上覆盖透明图像

[英]Overlay transparent image over clickable links

I'm trying to create a web page with a transparent image that appears overtop of text and clickable links.我正在尝试创建一个 web 页面,其透明图像显示在文本和可点击链接的上方。 Here is the mockup that I want it to look like, and here is the current site and the repo .这是我希望它看起来像的样机这是当前站点repo The overlay is the plant image.叠加层是植物图像。

I can think of a few ways this can be done, but I'm not sure the best way to do it.我可以想到一些可以做到这一点的方法,但我不确定最好的方法。 Perhaps there's another way I haven't considered too.也许还有另一种我没有考虑过的方法。 Here is what I'm thinking about doing:这是我正在考虑做的事情:

  1. Clip the plant image very carefully so that it appears as an image with a yellow background, and then the rest of the plant appears as part of the background of the internal frame.非常小心地剪辑植物图像,使其显示为带有黄色背景的图像,然后植物的 rest 作为内部框架背景的一部分出现。

  2. Overlay the plant image on the text (perhaps using z-index?), make the navigation menu a graphic as well (so it appears in front), and then use image mapping to select the links.将植物图像覆盖在文本上(可能使用 z-index?),使导航菜单也成为图形(因此它出现在前面),然后使用图像映射到 select 链接。

Any other ideas would be greatly appreciated.任何其他想法将不胜感激。 My solution should probably be compatible with the usual browser suspects (say, IE > 7/8).我的解决方案可能应该与通常的浏览器嫌疑人兼容(例如,IE > 7/8)。 Thank you.谢谢你。

You can go for option number one, except that you don't have to clip the image.您可以使用 go 作为选项一,但您不必剪切图像。

You can simply apply the same background image to both div s, and the browser will take care of the clipping for you.您可以简单地将相同的背景图像应用到两个div ,浏览器会为您处理剪辑。 You'll have to provide exactly correct px offsets for the two backgrounds.您必须为两个背景提供完全正确的px偏移量。

Here's a very rough demo: http://jsfiddle.net/zbZKG/这是一个非常粗略的演示: http://jsfiddle.net/zbZKG/

Here's a second one that works better when you reduce the window width: http://jsfiddle.net/zbZKG/1/这是第二个在减小 window 宽度时效果更好的方法: http://jsfiddle.net/zbZKG/1/

The box-shadow and the plant would interact more pleasantly if you used an rgba colour with some transparency for the shadow, something vaguely like rgba(0, 0, 0, 0.6) .如果您使用具有一定透明度的rgba颜色作为阴影, box-shadow和植物会更愉快地交互,有点像rgba(0, 0, 0, 0.6)

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

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