搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

CSS styles are only applied, if I change one in the developer tools

  • 2 回覆
  • 1 有這個問題
  • 5 次檢視
  • 最近回覆由 fritzmg

more options

On a particular website we are developing we have a peculiar problem where CSS styles that we change are not applied at all at first (with a cleared cache of course), but only if we disable and then re-enable any CSS style on the site via the inspector in the developer tools.

And in some cases it looks like some CSS styles are sort of "messed up", i.e. there seem to be margins or paddings applied where they shouldn't be. And these problems go away as soon as you open the developer tools (or the inspector in particular).

Furthermore the inspector shows CSS styles that appear to have other CSS selectors as their content (see attached screenshot to see what I mean). While this looks like the underlying stylesheet has syntax errors: the stylesheet is fine and has been validated with https://jigsaw.w3.org/css-validator/ - so that shouldn't be the issue. Besides it works fine in Chrome and Safari.

I am at a loss how I could debug such an issue as I have never seen anything like it before. This only started to happen with FireFox 79.0 so I am wondering if other people have encountered something like this also.

On a particular website we are developing we have a peculiar problem where CSS styles that we change are not applied at all at first (with a cleared cache of course), but only if we disable and then re-enable ''any'' CSS style on the site via the inspector in the developer tools. And in some cases it looks like some CSS styles are sort of "messed up", i.e. there seem to be margins or paddings applied where they shouldn't be. And these problems go away as soon as you open the developer tools (or the inspector in particular). Furthermore the inspector shows CSS styles that appear to have other CSS selectors as their content (see attached screenshot to see what I mean). While this looks like the underlying stylesheet has syntax errors: the stylesheet is fine and has been validated with https://jigsaw.w3.org/css-validator/ - so that shouldn't be the issue. Besides it works fine in Chrome and Safari. I am at a loss how I could debug such an issue as I have never seen anything like it before. This only started to happen with FireFox 79.0 so I am wondering if other people have encountered something like this also.
附加的畫面擷圖

由 fritzmg 於 修改

所有回覆 (2)

more options

Firefox 79 is much more aggressive about caching CSS. You may need to Shift+click the Reload button (or use Ctrl+F5) to retrieve updated style sheets. https://wiki.developer.mozilla.org/docs/Mozilla/Firefox/Releases/79#CSS

But if you disabled cache in the dev tools, that shouldn't be an issue?? On other two oddities:

Opening the inspector usually alters the height or width of the viewport, which can trigger repainting. To take that out of the equation, can you "undock" the developer tools to a separate window?

I'm not sure what to make of your screenshot. Could there be some kind of transmission error?

more options

It is definitely not a caching issue. To be sure I always clear the cache completely before refreshing.

It is definitely not about the viewport or the repaint when changing the viewport. I already considered that and tested with an undocked developer tools window on a second screen. The issue disappears as soon as the developer tools are opened. Sometimes the issue even reappears, once the developer tools are closed (though I could not reproduce that reliably yet).

It should not be a transmission error, otherwise I would assume a lot of CSS styles would be broken (well, they are broken, but not really - as the described issues go away once I open the developer tools and/or disable & enable any style). Also these transmission errors would probably manifest in other browsers as well.

Conceivably the issue shown in the screenshot could also be an error in the used sourcemap file - however, since there is no such issue in Chrome/Edge I am assuming that the sourcemap file is valid.