当使用最新版本的谷歌浏览器浏览我的网站并使用 F12 查看源代码时,<head>
和 </head>
之间的所有内容都显示为空。在最新版本的Firefox和IE上,所有内容看起来都是相关的。
实际上,内容已移至谷歌浏览器上的正文中。
这显然不是CSS问题。我正在使用Twitter Bootstrap CSS和JS,以及MVC PHP框架。有人有提示吗?
这是我的文档.html页面:
<!DOCTYPE html>
<html lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title><?php echo (Template::$titre); ?></title>
<?php foreach(Template::$meta as $key=>$value): ?>
<meta name="<?php echo $key; ?>" content="<?php echo $value; ?>" />
<?php endforeach; ?>
<link rel="shortcut icon" href="<?php echo WEB; ?>assets/style/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="<?php echo WEB; ?>assets/style/bootstrap.min.css" />
<link rel="stylesheet" href="<?php echo WEB; ?>assets/style/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="<?php echo WEB; ?>assets/style/main.css" />
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<?php require Template::child(); ?>
(...)
以及Firebug查看的来源:
<html lang="fr"><head></head><body>?
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Vélos d'occasion dans toute la France</title>
<meta name="keywords" content="velos d'occasion, velos dans toute la France, velos occasion Toute la france, velo occasion, velo">
<meta name="description" content="Petites annonces de velos d'occasion dans toute la France, velo d'occasion à vendre Toute la france">
<link rel="shortcut icon" href="/assets/style/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="/assets/style/bootstrap.min.css">
<link rel="stylesheet" href="/assets/style/bootstrap-responsive.min.css">
<link rel="stylesheet" href="/assets/style/main.css">
<link href="http://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<section id="maincontainer">
<div class="container">
(...)
编辑:问题解决了,记事本++以UTF8编码,我更改为ANSI并且工作正常。
文档开头有某种格式错误的字符。
我通过W3C验证器运行了您的页面,它显示:
错误行 1,第 1 列:在未看到 文档类型优先。预期
<!DOCTYPE html>
.
http://validator.w3.org/check?uri=http%3A%2F%2Fveloccasion.net%2F&charset=%28detect+automatically%29&doctype=Inline&group=0
这似乎导致Chrome删除您的文档类型并以Quirks模式呈现页面,正如您可以通过有趣的按钮和文本字段高度看到的那样。尝试在 DOCTYPE 之前删除任何奇怪的内容(或删除 DOCTYPE 并重新键入)
要以 Elijah 的答案为基础,请使用 CTRL+U 在 chrome 和 Firefox 上查看源代码。
我刚刚检查了铬,它不是空的。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Veloccasion - Vélos d'occasion dans toute la France</title>
<meta name="keywords" content="velos d'occasion, velos dans toute la France, velos occasion Toute la france, velo occasion, velo" />
<meta name="description" content="Petites annonces de velos d'occasion dans toute la France, velo d'occasion à vendre Toute la france" />
<meta name="author" content="Veloccasion.net" />
<link rel="shortcut icon" href="/assets/style/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="/assets/style/bootstrap.min.css" />
<link rel="stylesheet" href="/assets/style/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="/assets/style/main.css" />
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
F12 不是查看源代码。F12 是 DOM 检查器。有没有可能你只是看到头部塌陷?这是默认情况下的显示方式。
编辑:
发现您的问题:
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
该标记不会关闭。你需要用/>
结束它
编辑:
可能是您在/>
这一行之前需要一个空格:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
我找到了!
在镀铬中按 CTRL+SHIFT+I,
。紧跟在<body>
标签之后,有一行大量空白文本。找到它,然后删除它,空格就会消失。不确定是什么原因造成的,因为我没有您的代码。
希望对您有所帮助
下面的一行
<link href="http://fonts.googleapis.com/css?family=Lobster"
rel="stylesheet" type="text/css
注意其中的"?"尝试删除此行并查看源代码