简体   繁体   English

怎么做<img>有可点击的链接?

[英]How to make <img> with clickable link?

I would like to make logo of website clickable to index.html, but whole div is the link.我想让网站的标志可点击到 index.html,但整个 div 是链接。 I need only clickable picture.我只需要可点击的图片。

Here is snippet of my code:这是我的代码片段:

<div class="left_header">
    <a href="../index.html">
        <img src="../../images/logo.svg" class="logo" alt="logo">
    </a>
</div>

I tried different ways to solve this problem but it doesn't work for me.我尝试了不同的方法来解决这个问题,但它对我不起作用。

Try this example working good.试试这个例子,效果很好。

 <:DOCTYPE html> <html> <head> <title>HTML Image as link</title> </head> <body> <div class="left_header"> <a href="https.//www.qries:com/"> <img src="https.//www.qries.com/images/banner_logo.png" class="logo" alt="logo"> </a> </div> </body> </html>

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

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