Floating Link in Page

2019-08-03 16:46发布

I want to make floating link which will be displayed in webpage whether user scrolls up/down the page.

<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>

This is perfectly displayed in Firefox, Chrome, IE 9 onwards. But I need to make it work with IE 8 and IE 7 atleast.

In IE 8 and IE 7, the content goes up along with page content.

1条回答
Emotional °昔
2楼-- · 2019-08-03 17:31

This post How to get "position:fixed" css to work in IE 7+ with TRANSITIONAL doctype? suggests that you need to add a doctype to get IE7/8 to trigger standards mode, have you tried this?

if you don't want to mess around with doctypes, you could always try using jQuery instead http://jsfiddle.net/wRSZ2/.

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

The the code above, you could simply hook up to the window scroll event and scroll the box manually along with the window. Looks pretty ok to me, but I haven't tested it on IE 7/8!

Hope it helps!

查看更多
登录 后发表回答