Html 如何将url链接附加到图像?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1921726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:36:59  来源:igfitidea点击:

how to attach url link to an image?

htmlimageurlhyperlink

提问by Zach

I am creating an website. It contains videos of different places. Now my problem is i need integrate an image on that with url link. when user taps on that link it has to go to that link. Even user downloads the video also it has to go to that link (same link above linked to image).

我正在创建一个网站。它包含不同地方的视频。现在我的问题是我需要将图像与 url 链接集成在一起。当用户点击该链接时,它必须转到该链接。即使用户下载视频,它也必须转到该链接(上面链接到图像的相同链接)。

回答by Gregory Pakosz

"How to attach url link to an image?"

“如何将 url 链接附加到图像?”

You do it like this:

你这样做:

<a href="http://www.google.com"><img src="http://www.google.com/intl/en_ALL/images/logo.gif"/></a>

See it in action.

看到它在行动

回答by alex

Alternatively,

或者,

<style type="text/css">
#example {
    display: block;
    width: 30px;
    height: 10px;
    background: url(../images/example.png) no-repeat;
    text-indent: -9999px;
}
</style>

<a href="http://www.example.com" id="example">See an example!</a>

More wordy, but it may benefit SEO, and it will look like nice simple text with CSS disabled.

更罗嗦,但它可能有利于 SEO,它看起来像禁用 CSS 的漂亮简单文本。