我的网站在Firefox上完美加载,但CSS在Chrome上完全消失(尽管html加载)。
根据控制台,这似乎是因为Chrome正在将index.php的内容加载到main.css和bannerTest.css中,如下所示:
我尝试过的东西不起作用:
有什么问题?我甚至无法弄清楚采取什么措施来更深入地调查发生了什么,更不用说弄清楚问题本身了。据我所知,没有错误打印到控制台。
这是index.php:
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Study</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bannerTest.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
<link href="css/main.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"></script>
<style>
/**
* The banner assumes a margin of 0px, but is not included
* in banner.css to avoid collisions with other themes and
* admin bars.
*/
body {
margin:0px;
}
</style>
<link rel="icon" type="image/ico" href="favicon.ico">
</head>
<body>
<?php
//Connect to MySQL database.
$host = "127.0.0.1";
$user = "root";
$password = "password";
$database = "database";
$r = mysql_connect($host, $user, $password);
if (!$r) {
echo "Could not connect to server.\n";
trigger_error(mysql_error(), E_USER_ERROR);
}
$query = "CREATE DATABASE IF NOT EXISTS " . $database;
mysql_query($query);
@mysql_select_db($database) or die("Unable to select database.");
$query="CREATE TABLE IF NOT EXISTS `groupcodes` (`groupcode` int(10) PRIMARY KEY, `usercode` int(10))";
mysql_query($query);
$userid = "";
?>
<div id="banner">
<div id="u-header-container">
<div class="container">
<div class="row-fluid">
<div id="home-link-container">
<a id="home-link" href="http://csue.edu/">
<span id="wordmark">U</span>
<span id="university">UNIVERSITY</span>
</a>
</div>
</div>
</div>
</div>
<div id="database-container">
<header>
<a href="index.php">
<h4 id="logo">Computing Systems</h4>
<h1 id="study_logo">Study</h1>
</a>
</header>
<div id="study">
<form method="post" id="consent-form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="wide-column">
<p>
By clicking the 'Acccept' button below, you hereby acknowledge the following:
</p>
<p>
I am 18 years of age or older, live in the United States, and have a Google Drive or Dropbox account.
I have read this form and decided that I will participate in the project described above.
Its general purposes, the particulars of involvement, and possible risks and inconveniences have
been explained to my satisfaction. I understand that I can withdraw at any time.
</p>
</div>
<input type="text" name="email_input">
<br>
<input type="submit" value="Begin Study">
</form>
</div>
</div>
</div>
</body>
</html>
答案 0 :(得分:1)
你误诊了这个问题。这是因为访问不同的URL来加载HTML文档而不是使用不同的浏览器。您只需在切换网址的同时切换浏览器。
查看第一张图片中正在加载的网址:
http://localhost/peergroup/index.php/css/main.css
在Chrome中,您必须在访问http://localhost/peergroup/index.php/
的Firefox中访问http://localhost/peergroup/index.php
(最后没有/
)。
这导致相对URL的计算方式不同。
解决方法是使用相对于网站根目录的网址(即以/
开头)。