html - 悬停时图像显示对齐仅适用于 IE7?

标签 html css

当鼠标悬停在文本上时,我试图显示图像。它工作正常。并且应显示图像的对齐方式,以使图像的末尾应位于容器中。它适用于下面显示的代码,仅在 IE7 中。在所有方面,它都被砍掉了……这里有什么问题?

<td valign="middle" class="table_td td" style="width: 347px">
   <span class="feature_text" style="cursor:pointer" 
   onmouseover="ShowPicture('Style16',1)" 
       onmouseout="ShowPicture('Style16',0)" id="a16">
               Storefront Window Decal</span>
    <div id="Style16" style="position:relative;height:0px;left:50%;bottom:700%;
        visibility:hidden; border:solid 0px #CCC; padding:5px">
        <img src="images/window-decal-image.gif"></div> 

<script language="javascript" type="text/javascript">
 function ShowPicture(id,Source) 
 {
    var vis, elem;
    if (1 == Source)
    {
         vis = "visible";
    }
    else if (0 == Source)
    {
       vis = "hidden";
    }
    else
    {
       throw new RangeError("Unknown Flag");
    }

    if (elem = document.getElementById(id))
    {
       elem.style.visibility = vis;
    }
    else
    {
       throw new TypeError("Element with id '"+id+"' does not exist.");
    }
    return vis;
}
</script>

谁能帮帮我。提前致谢!!

最佳答案

我建议使用 background-image在你的 div 而不是单独的 <img>标签,和 background-position:right;根据您的要求对齐它。

您可能需要一些其他相关的 CSS 才能使其完美(可能是 background-repeat?),但我建议您这样做。

我还建议将所有样式代码移至单独的 CSS <style>元素来减少 HTML 代码中的困惑并使其更具可读性。

关于html - 悬停时图像显示对齐仅适用于 IE7?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4594551/

相关文章:

html - UIWebview - 文本切割

javascript - 检测对带有扩展 javascript 的动态下拉框的点击

html - 移动 View 右侧的 Bootstrap 空白

ios - Tableview Xib Shadow Swift

javascript - 使用javascript切换div的动态高度

javascript - 如何让车子朝怪物方向行驶

javascript - 在多个页面上自动进行 javascript 和 html 测试

javascript - JQuery 错误 : cannot call methods on dialog prior to initialization; attempted to call method 'close'

html - 带有内联样式的可折叠列表 - 可能吗?

javascript - CSS new 'content-visibility' 属性是否会干扰脚本加载行为?