如何在 html 中使图像可点击
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42051528/
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
how do i make an image clickable in html
提问by Hyman reacher
here is the html
这是html
<div id="panelpic1">
<a href="https://www.google.com/"style="display:block"target="_blank">
</a>
</div>
CSS
CSS
#panelpic1{
content: url(file:///D:/MOHIT/HTML/images.jpg);
float: left;
width: 250px;
height: 150px;
vertical-align: middle;
}
This is the way i did it, but its not working . The image is not clickable. please help
这是我这样做的方式,但它不起作用。图片无法点击。请帮忙
回答by Mukul Jain
<!DOCTYPE html>
<html>
<body>
<span>Open image link in a new tab:
<a href="http://www.google.com" target="_blank">
<img src="D:/MOHIT/HTML/images.jpg" />
</a>
</span>
</body>
</html>
This is not the best approach. Here is one of the standard approaches to make image clickable.
这不是最好的方法。这是使图像可点击的标准方法之一。
<a href="your landing page url">
<img src="your image url" />
</a>
Now, this image will redirect to you on specified URL on click.
现在,此图像将在单击时重定向到指定的 URL。
There are many ways to do it from uploading it S3/dropbox to using FSCollection (that's for node users only).
从上传 S3/dropbox 到使用 FSCollection(仅适用于节点用户),有很多方法可以做到这一点。
So in your case, your snippet will look like this,
所以在你的情况下,你的片段看起来像这样,
<a href="http://www.google.com">
<img src="D:/MOHIT/HTML/images.jpg" />
</a>