强制浏览器加载CSS显示页面之前 [英] Force browsers load CSS before showing the page

查看:114
本文介绍了强制浏览器加载CSS显示页面之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了我的网站的移动版本。然而,当加载网页,首先显示没有应用CSS的网站,和第二(至多)后其应用了CSS和正常显示它。此行为是在所有浏览器(包括移动的)是一致的。

你有什么想法,我怎么可能会迫使浏览器第一次加载CSS(这是真正的规模很小)和然后的呈现内容?我已经看到一些关于包括之外的CSS文件,但据我所知,这是对的规格,我在某些移动害怕这样黑客可以刹车的事浏览器。

谢谢!

更新

下面是源

 <?XML版本=1.0编码=UTF-8&GT?;
!< D​​OCTYPE HTML PUBLIC - // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
< HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>
  < HEAD>
    <标题>钠长石图书行动< /标题>
    < META HTTP-EQUIV =Content-Type的CONTENT =是application / xhtml + xml的;字符集= UTF-8/>
    < META NAME =说明内容=免费电子书的Java手机。/>
    < META NAME =关键词内容=免费电子书,免费书籍,电子书阅读器,读者钠长石,钠长石的书,Java移动/>
    < META NAME =语文内容=EN_GB/>
    < META NAME =分类内容=公/>    <链接rel =快捷方式图标的href =favicon.ico的/>
    < META NAME =视口CONTENT =WIDTH =设备宽度,初始规模= 1,最大规模= 1/>
    <链接HREF =?/样式表/ mobile.css 1289644607媒体=屏幕的rel =stylesheet属性类型=文/ CSS/>
  < /头>
  <身体GT;
  <! - ... - >
  < /身体GT;
< / HTML>


解决方案

你有没有想过你的缓存CSS文件的?

I've made a mobile version of my site. When loading the page however, the site is first shown without the CSS applied, and after a second (at most) it applies the CSS and renders it properly. This behaviour is consistent across all browsers (including mobile ones).

Do you have any idea, how I could force browsers to load the CSS first (which is really tiny in size) and then render the content? I've seen something about including the CSS files outside the head, but as far as I know it's against the specs, and I am afraid such hack may brake things on some mobile browsers.

Thanks!

Update

Here's the source

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Albite BOOKS mobile</title>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
    <meta name="description" content="Free e-books for Java Mobile phones."/>
    <meta name="keywords" content="free ebooks, free books, book reader, albite reader, albite books, java mobile"/>
    <meta name="language" content="en_GB"/>
    <meta name="classification" content="public"/>

    <link rel="shortcut icon" href="favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link href="/stylesheets/mobile.css?1289644607" media="screen" rel="stylesheet" type="text/css" />
  </head>
  <body>
  <!-- .... -->
  </body>
</html>

解决方案

Have you thought of caching your CSS file?

这篇关于强制浏览器加载CSS显示页面之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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