How do I make an image clickable?

时光毁灭记忆、已成空白 提交于 2020-12-26 06:39:58

问题


Here is the html:

<div id="panelpic1">
    <a href="https://www.google.com/"style="display:block"target="_blank">
    </a>
</div>

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 it is not working. The image is not clickable. What to do?


回答1:


<!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.

There are many ways to do it from uploading it S3/dropbox to using FSCollection (that's for node users only).

So in your case, your snippet will look like this,

<a href="http://www.google.com">
 <img src="D:/MOHIT/HTML/images.jpg" />
</a>


来源:https://stackoverflow.com/questions/42051528/how-do-i-make-an-image-clickable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!