css - 背景附件 :fixed doesn't work for SPAN element in IE8

标签 css internet-explorer-8 internet-explorer-9 html

似乎 background-attachment:fixed CSS 属性值不适用于 Internet Explorer 8 中的 SPAN 元素,尽管 W3C 和所有其他来源都说IE 确实支持“固定”值,没有任何限制。 我的简单 html 如下:

<!DOCTYPE html>
<html>
    <head>
        <title></title> 
         <STYLE type="text/css">
            span {
                background-image:url(empty-bg.png);
                background-repeat:repeat;   
                background-position:0 0;
                background-attachment:fixed;
            }
         </STYLE>
    </head>
    <body>
        Text<br/>
        Text<br/>
        Text<br/>
        Text<br/>
        Text<br/>
        Text<br/>
        <span>HOLE</span><br/>
        Text<br/>
        Text<br/>
        Text<br/>
        Text<br/>
        Text<br/>
        Text<br/>
        Text<br/>
    </body>
</html>

我的期望是当滚动这个页面时背景图片应该保持固定,所以它会在页面中产生空洞的错觉,这在 Firefox 中工作得很好,但在 IE 中它的行为就像它被设置为 <强>滚动。 IE 有任何解决方法吗?

最佳答案

您是否尝试过将 display: inline-block; 用于 span 元素?

无论如何,请注意,实际上 IE 对 background-attachment:fixed 的支持有很多问题,请检查 http://www.standardista.com/css3/css3-background-properties/#bg1 .如您所见,在 IE7 之前,它将“固定”值视为“滚动”,而 IE8 可能会错误地放置图像。

关于css - 背景附件 :fixed doesn't work for SPAN element in IE8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14860276/

相关文章:

javascript - 中心位置CSS

html - 优先考虑 CSS 类?

jquery - 如何增加滑出的宽度

c# - 如何以编程方式关闭 IE8 WebBrowser 控件中的怪癖模式?

HTML 5 w3c 验证

html - Internet Explorer 9 和 10 的 CSS 问题

jquery - 从滚动触发的不同元素的效果(取决于当前屏幕位置)

javascript - AngularJS - IE8 - 将 $index 传递给 ng-click 中的函数始终返回 0 并执行多次

IE7 和 IE8 中的 CSS 问题 - &lt;input type ="text"> 字段上的文本缩进

joomla - TinyMCE 无法在 IE9 中工作