固定div不会在Chrome中更新,除非在页面顶部或页面滚动 [英] fixed div does not update in Chrome unless at top of page or page scrolls

查看:159
本文介绍了固定div不会在Chrome中更新,除非在页面顶部或页面滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一篇文章,所以我希望我用正确的方式。

This is my first post, so I hope I am going about it the right way.

我的页面顶部有一个div:

I have a div at the top of my page:

#data
{
    display: inline;
    position: fixed;
    z-index: 1999;
    top: 20px;
    right: 20px;
    width: 300px;
    text-align: center;
}

然后使用定时器和以下jQuery更新:

I then update this using a timer and the following jQuery:

$('#secondsToSave').html(SecondsToSave);

其中#secondsToSave是#data div中的一个范围。

where #secondsToSave is a span within the #data div.

这在Firefox中工作正常,并且在Chrome提供我滚动到页面的顶部。但是,一旦我在页面上向下滚动一下,该范围将停止在屏幕上更新。计数器仍然工作,它似乎是没有更新的屏幕。一旦我做了一些事情,例如滚动页面,甚至检查元素,屏幕更新,但它什么也不做,屏幕不更新。

This works fine in Firefox, and in Chrome provided I am scrolled to the top of the page. However, as soon as I scroll down on the page a bit, the span stops updating on the screen. The counter is still working, it just seems to be the screen that is not updating. As soon as I do something, such as scrolling the page or even inspecting the element, the screen updates, but it I do nothing the screen does not update.

任何帮助

推荐答案

为您的元素提供id为secondsToSave的下列样式。

Give your element with the id "secondsToSave", the following style.

style="position: relative"

我不知道为什么,但它解决了这个问题。

I don't know why but it fixes the issue.

这篇关于固定div不会在Chrome中更新,除非在页面顶部或页面滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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