html - 背景图片上的链接

标签 html css image hyperlink background

我想在背景图片上使用链接(参见示例 http://goo.gl/GfkD6M )。如何添加指向该图片的部分(例如形状)的链接,如文本“Link1”和“Link 2”所示?

最佳答案

你不能那样做,但有几种方法可以间接地做到这一点:

1.您可以使用分离图像。

2.在图片上放一个索引比图片低的div

.getclick_link1 {
      /* Get the position and width of Link1 with F12 in Chrome */
      z-index : <put a z-index for the image> - 1;
      width : <the width of Link1> ;
      height : <the height of Link1>;
      position : absolute;
      left : <Get the left position of Link1 in the image>;
      top : <Get the top position of Link1 in the image>;
}

在 JQuery 中这样做:

$(function(){
    $(".getclick_link1").click(function() {
        window.location = "The address you like to redirect"
    });
});

关于html - 背景图片上的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31317741/

相关文章:

html - 为我们的门户解决firefox中的浏览器冲突

html - 如何在 WordPress 中创建打字效果

css - 所有 IE 中的 abs 定位搜索栏有问题吗?

javascript - 是否有可能css显示:block after jquery display:none?

javascript - 使用 CamanJS 的图像查看器/编辑器

java - 为什么从 .jar 文件运行时没有图像?

html - 使用 CSS 的动态边距

javascript - 使用 TD 标签的数据创建数组

css - 从公共(public) Assets 下的 css 文件导入另一个 css 文件不适用于 play 2.0.4

css - E4 RCP CTabFolder 图像投影