app dir
css
style.css
inc
header.inc.php
footer.inc.php
index.php
login.php
register.php
的style.css包括在的header.inc.php更新包括CSS文件
<?php
//Include a error reporting:
include '../../errorReport.inc.php';
// Set default timezone:
define('TZ', date_default_timezone_set('America/Los_Angeles'));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>
<?php
if(defined('TITLE'))
{
print TITLE;
} else {
print 'Raise High the Roof Beam! A J.D. Salinger Fan Club';
}
?>
</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="./c/screen.css" media="screen,projection" />
</head>
在創建一個新的頁面(login.php中)的目標是將樣式應用到包括( d)標題中的CSS。不是簡單地把CSS的標記,在任何地方,下面是我的嘗試,它已經失敗:
<?php
header('content-type:text/css', replace);
header("Expires: ".gmdate("D, d M Y H:i:s", (time()+900)) . " GMT");
$errorColor = '#900';
echo '.error{ color: '.$errorColor.'; }';
?>
<?php include 'inc/header.inc.php';?>
<p class=\"error\">Error MSG</p>
<?php include 'inc/footer.inc.php';?>
這是打印到UA:
.error{ color: #900; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>
Raise High the Roof Beam! A J.D. Salinger Fan Club </title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="./c/screen.css" media="screen,projection" />
</head>
<body>
<div id="wrapper">
.................................
如果你輸出文本/ CSS MIME類型,那麼整個文件應該是CSS。在某些HTML中添加只會導致無效/破壞的CSS。 –