什么可能导致CSS无法在所有浏览器上偶尔加载? [英] What might cause CSS to fail to load occassionally on all browsers?

查看:145
本文介绍了什么可能导致CSS无法在所有浏览器上偶尔加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个webapp,并且经常遇到的情况下,页面将加载而不应用CSS。此问题已在IE6,IE7,Safari 3和FF3中出现。

I'm working on a webapp, and every so often we run into situations where pages will load without applying CSS. This problem has shown up in IE6, IE7, Safari 3, and FF3.

页面刷新将始终解决问题。

A page refresh will always fix the problem.

使用@import在同一样式块中加载3个CSS文件:

There are 3 CSS files loaded, all within the same style block using @import:

<STYLE type="text/css">
  @import url([base css file]);
  @import url([skin css file]);
  @import url([generated css path]);
</STYLE>

在任何情况下,当我们花时间检查html源时,没有什么是不寻常的。访问日志看起来也很正常 - 我们每次请求时都会获得静态CSS文件的HTTP 304响应,并为我们生成的CSS提供HTTP 200响应。

In any situation when we take the time to examine the html source, nothing is out of the ordinary. Access logs seem normal as well - we're getting HTTP 304 responses for the static CSS files whenever they are requested, and an HTTP 200 response for our generated CSS.

mimetype是css文件和生成的css的文本/ css。我们正在使用iPlanet服务器,它会将请求转发到Tomcat服务器。

The mimetype is text/css for the css files and the generated css. We're using an iPlanet server, which forwards requests to a Tomcat server.

davebug问:


它是否总是相同的css文件不加载,或者是所有的问题,均匀?

Is it always the same css file not loading, or is the problem with all of them, evenly?

没有任何CSS文件加载。

None of the CSS files load. Any styles defined within the HTML work fine, but nothing in any of the CSS files works when this happens.

推荐答案

我在HTML文件中定义的任何样式都能正常工作。有一个类似的事情发生,我能够通过包括基本样式表首先使用链接rel方法,而不是@import。即将您的[基本css文件]包含到:

I've had a similar thing happen that I was able to fix by including a base style sheet first using the "link rel" method rather than "@import". i.e. move your [base css file] inclusion to:

<link rel="stylesheet" href="[base css file]" type="text/css" media="screen" />

并将其放在其他人之前。

and put it before the others.

这篇关于什么可能导致CSS无法在所有浏览器上偶尔加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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