伪造IE6中的固定位置 [英] Faking Fixed Position in IE6

查看:74
本文介绍了伪造IE6中的固定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有一个使用底部固定位置标头的网站: http://www.entheospartners.com /newsite/

I have a site that utilizes a bottom fixed position masthead here: http://www.entheospartners.com/newsite/

此设置在除IE6之外的所有浏览器中都很好用,IE6至少不支持固定定位,所以这是我要做的事情:

This setup works great in all browsers except IE6, which doesn't support fixed positioning in the least, so here's what I've done:

当IE6用户来到页面时,我使用以下代码来确定是否需要滚动:

When an IE6 user comes to the page, I make the determination if scrolling is necessary using this bit of code:

var windowHeight = $(window).height();
var totalHeight = windowHeight - 100; // where 100 is the sum of the top nav height + footer height
var contentHeight;

if($('#subpage-content-small').length) { // main content div for a three column layout
    contentHeight = $('#subpage-content-small').height();
};

if($('#subpage-content-wide').length) { // main content div for a two column layout
    contentHeight = $('#subpage-content-wide').height();
};

if(contentHeight > totalHeight) {
    $('#container-container').css({
        'overflow-y' : "scroll",
        'height' : totalHeight
    });
};

...可以正确计算所有内容,将滚动条放置在需要放置的位置(向右平移),然后将其设置为适当的高度.问题在于滚动条不会移动内容.我不能说我以前见过类似的东西,所以我希望这里的其他人有.预先感谢!

...which calculates everything correctly, puts the scrollbars where they need to be (flush right), and sets them to the appropriate height. The problem is that the scrollbars don't move the content. I can't say that I've ever seen anything quite like this before, so I'm hoping someone else on here has. Thanks in advance!

PS-显然,这需要在IE6中进行检查以进行故障排除,我知道这对您和我来说都会很痛苦.

PS - Obviously, this needs to be looked at in IE6 for troubleshooting, which I know will be as painful for you as it is for me.

更新

在进一步研究CSS表达式之后,基于第一个答案,我得出了一个解决方案,该解决方案用于将菜单固定在页面的顶部.我需要的是能够使用它并将其应用到页面底部.这并不像将所有顶部"切换为底部"那么简单,所以我希望有人能启发我.这是CSS:

After a little more digging on CSS expressions, based on the first answer, I came to a solution that works for fixed positioning the menu to the TOP of the page. All I need is to be able to use this and apply it to the bottom of the page. It's not as simple as switching all "top"s to "bottom"s, so I'm hoping someone can enlighten me. Here's the CSS:

#divfixed { 
    position: absolute; 
    top: expression(0+((e=document.documentElement.scrollTop)?e:document.body.scrollTop)+'px'); 
    left: expression(0+((e=document.documentElement.scrollLeft)?e:document.body.scrollLeft)+'px');}

推荐答案

在基于CSS表达式进行了更多研究之后,我遇到了一个非常有用的jQuery插件,该插件非常适合我:

After more research based on CSS expressions, I came across a helpful jQuery plugin that is working perfectly for me: http://chrisiona.com/fixedposition/

我使用条件定位IE6,并将页脚栏定位在绝对底部,然后应用fixedPosition插件,效果很好.我不能预料到我会再使用此插件太多次,但希望它能够帮助其他人.

I'm using a conditional to target IE6 and positioning the footer bar absolute bottom, then applying the fixedPosition plugin and it's working great. I can't envision too many other times I would be using this plugin, but hopefully it'll be able to help someone else out.

这篇关于伪造IE6中的固定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆