< a& gt;内的图片和文字标签 [英] Image and text inside of <a> tag

查看:90
本文介绍了< a& gt;内的图片和文字标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是生成的html asp.net(已删除一些标识客户端的详细信息)

This is the html asp.net generated (with some client-identifying details removed)

在Windows XP/IE 7中,单击图像不会执行任何操作.单击文本将执行超链接.右键单击任意位置,然后选择在新窗口中打开 open 也是可行的.

In Windows XP / IE 7 clicking on the image does nothing. Click on the text executes the hyperlink. Right-clicking anywhere and then selecting open in new window or open also works.

在其他浏览器中,它们都能按预期工作.

In other browsers, it all works as expected.

有没有简单的人可以看到我可以做到的事情,以使其在IE7中正常工作?

Is there anything simple anyone can see that I could do to this to get it to work correctly in IE7?

<div id="hdrXXX">                      
            <a id="ctl00_XXX" title="XXX" class="hdrXXX" href="http://google.com" target="_blank">
                 <div style="float:left;display: block;"> 
                    <img id="ctl00_XXX" src="Images/XXX.png" style="border-width:0px;" />
                </div>
                <div style="float:left; display: block; padding:15px 0 0 0;"> 
                    <span id="XXX">Some text right here</span>

                </div>
            </a>  
       </div>  

推荐答案

您只能将块级元素放在具有HTML5的锚点元素内,而浏览器支持仍然有些悬念.IE7显然不支持此功能.

You can only put block-level elements inside anchor elements with HTML5 and browser support is still a bit iffy on it. IE7 obviously does not support this.

您无需使用除法即可做到这一点:

You don't need to use division to do this:

<div id="hdrXXX">                      
    <a id="ctl00_XXX" title="XXX" class="hdrXXX" href="http://google.com" target="_blank">
        <img id="ctl00_XXX" src="Images/XXX.png" style="border: 0; float: left; margin-right: 15px" /> 
        <span id="XXX">Some text right here</span>
    </a>  
</div>

这应该可以达到相同的效果...

This should work to the same effect...

这篇关于&lt; a&amp; gt;内的图片和文字标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆