简体   繁体   English

<img>标签内的<a>标签仅在IE中有效</a>

[英]<img> tag inside an <a> tag works only in IE

I'm trying to make a logo image, which should work as a hyperlink and redirect the user to the Home Page when clicked. 我正在尝试制作徽标图像,该徽标图像应用作超链接,并在单击时将用户重定向到主页。

<a class="fleft block" href="../../Pages/HomePage.aspx">
    <img class="logo" src="../../Images/logo.gif" alt="Logo" /></a>

This code works fine in IE, it behaves as expected. 此代码在IE中可以正常工作,其行为符合预期。 However the image is not clickable in FireFox, Chrome, Opera and Safari. 但是,该图像在FireFox,Chrome,Opera和Safari中不可点击。

Any ideas why? 有什么想法吗? Thanks, Anton 谢谢,安东

EDIT: Alright guys, thanks for the answers. 编辑:好的,谢谢你的回答。 I've removed my css classes (float: left and display: block) and now it's working 我已经删除了我的CSS类(浮动:左,显示:块),现在可以正常工作了

Do you float the link ? 您是否浮动链接? if you do so it will not encapsulate the entire image. 如果这样做,将不会封装整个图像。 if this is the case, you might want to give your link a widht and height in css. 如果是这种情况,则可能需要为链接指定CSS的宽度和高度。

.fleft.block{
  width: "your image width";
  height: "your image height";
}

Your code is working fine. 您的代码运行正常。 If you want to change the cursor over image, try this in your CSS; 如果要在图像上更改光标,请在CSS中尝试;

.logo{
  cursor: pointer;
}

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

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