< a>内部的图像和文本标签 [英] Image and text inside of <a> tag

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

问题描述

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

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

在Windows XP / IE 7中单击图像什么也不做。点击文本执行超链接。右键单击任何位置,然后选择在新窗口中打开打开也可以。

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和浏览器支持仍然有点iffy它。 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&gt;内部的图像和文本标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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