Floating Link in Page

筅森魡賤 提交于 2019-12-24 07:46:48

问题


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:


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!



来源:https://stackoverflow.com/questions/11345546/floating-link-in-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!