0

我有一个页面,其中包含从正文中的数据库中提取的一些内容,在头部我有一个链接到格式化该内容的外部样式表。在 Safari 上(在 Chrome 或 Firefox 上似乎没有)我得到了一个可爱的无样式内容的闪光。

我宁愿对此进行非javascript修复,有没有办法定位外部css工作表链接,以便在php脚本在正文中运行之前应用它?- 我认为它会自动执行此操作,但显然不是在野生动物园中,有什么想法吗?

<?php
require_once "../config/article_functions.php";
include "../widgets/topborder.html";
include "../widgets/banner.php";
include "../widgets/navbar.html";
?>

<!DOCTYPE html>
<html>
<head>

<link rel="stylesheet" type="text/css" href="http://example.org/widgets/article.css">

<style type="text/css">
a:link {color: inherit;}      /* unvisited link */
a:visited {color: inherit;}  /* visited link */
a:hover {color: inherit;}  /* mouse over link */
a:active {color: inherit;}  /* selected link */

body, html {
    margin: 0;
    padding: 0;
    height:900px;
}

#container {
    width:990px;
    height:1000px;
    margin-left:auto;
    margin-right:auto;
}

#news_container {
    width:740px;
}

</style>
<title> TODO </title>

</head>
<body>
<div id="container">
    <?php include "../widgets/sidepanel.html"; ?>
    <div id = "news_container">
        <?php
            $uri = explode('/', $_GET['$url']);
            get_selected_news($uri[0]);
        ?>
    </div>
</div>
</body>
</html>

一秒钟左右,我看到了这个:

在此处输入图像描述

然后之后: 在此处输入图像描述

4

1 回答 1

4
<?php
include "../widgets/topborder.html";
include "../widgets/navbar.html";
?>

<!DOCTYPE html>
<html>
<head>
…

坏小子!难怪 Safari 在 doctype 声明之前获取 HTML 时会感到困惑。也许它甚至在</html>看到你的样式表之前就得到了一个结束标签?

于 2014-06-07T16:53:15.440 回答