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

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

问题描述

我正在开发一个Web应用程序,每隔一段时间我们就会遇到一种情况,即页面加载时不应用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.

已加载3个CSS文件,所有文件都使用@import放在同一样式块中:

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.

MIME类型是CSS文件和生成的CSS的text/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文件.在HTML中定义的任何样式都可以正常工作,但是在这种情况下,任何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.

推荐答案

我发生了类似的事情,我可以通过使用链接相关"方法而不是"@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" />

并放在其他人之前.

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

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