修复滚动条上的标头在ie8中不起作用 [英] fixed header on scroll not working in ie8

查看:88
本文介绍了修复滚动条上的标头在ie8中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户向下滚动标题时,我已经为修订标题实现了一个jquery,它将获得修订位置.但是它可以在除ie8之外的所有浏览器中使用.谁能建议正确的方法.

i have implemented a jquery for fix header when user scrolls down the header will get fix position. But it is working in all browser except ie8. could anyone suggest the correct way.

$(document).ready(function()
{
    $(document).scroll(function()
    {
        var window_y = $(window).scrollTop();
        var header_h = $('.header').height();
        if(window_y > header_h)
        {
            $(".header").addClass('fixed');
        }
        else
        {
            $(".header").removeClass('fixed');
        }
    });
});

工作参考位于此处.

推荐答案

尝试一下,这样可以正常工作,或者您也可以在不使用make的情况下提供固定高度的标题 标头的变量请尝试第一个控制台

try this and this will work fine or also you can give fixed height of header without make variable of header pls try first console

$(window).scroll(function () {
    var header_h = $('.header').height();
    //console.log(header_h);
    if ($(this).scrollTop() > header_h) 
    {
        $(".header").addClass('fixed');
    } 
    else 
    {
        $(".header").removeClass('fixed');
    }
});

尝试时告诉我是否有任何问题

let me know if you have any issue when you try this

这篇关于修复滚动条上的标头在ie8中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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