页面中的浮动链接

时间:2012-07-05 13:39:31

标签: html internet-explorer-8 css-float

我想制作浮动链接,无论用户在页面上下滚动,都会在网页上显示。

<div id="valids" style="position: fixed; bottom: 5px; left: 5px;">
<a href="http://validator.w3.org/check?uri=referer" class="valid">
<img alt="Valid XHTML 1.0" src="http://www.w3.org/Icons/valid-xhtml10-blue" style="border: 0pt none ; width: 88px; height: 31px;"/></a>
<a href="http://jigsaw.w3.org/css-validator/validator?uri=http://www.reapercharlie.com" class="valid">
<img alt="Valid CSS 2.1" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" style="border: 0pt none ; width: 88px; height: 31px;"/></a>
</div>

这在Firefox,Chrome,IE 9以上完美展示。 但我至少需要使用IE 8和IE 7。

在IE 8和IE 7中,内容随页面内容一起上升。

1 个答案:

答案 0 :(得分:2)

这篇文章How to get "position:fixed" css to work in IE 7+ with TRANSITIONAL doctype?建议你需要添加一个doctype来让IE7 / 8触发标准模式,你试过吗?

如果您不想使用doctypes,可以尝试使用jQuery而不是http://jsfiddle.net/wRSZ2/

$(window).scroll(function() {
    var scrollTop = $(window).scrollTop();
    $("#mybox").css("top", scrollTop + "px");
});​

上面的代码,您可以简单地连接到窗口滚动事件并手动滚动框与窗口。看起来对我很好,但我没有在IE 7/8上测试过它!

希望它有所帮助!