我想使用 html 和 css 创建一个模板,所以我创建了以下 template.html 文件:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Application</title>
<link href="CSS/layout.css" rel="stylesheet" />
<script src=""></script>
</head>
<body>
<div class="wrapper">
<div class="header">
<!--<div class="header_left"></div>
<div class="header_right"> -->
<h3>Application</h3>
<h4>**** Project ****</h4>
</div>
<div class="navbar">
<ul class="mainnavbar">
<li><a href="#">Home</a></li>
<li><a href="login.html">About</a></li>
<li><a href="#">Description</a></li>
<li><a href="#">Contact Me</a></li>
</ul>
</div>
<div class="mainbody">
<div class="leftcol">
<div class="left_navbar">
<ul class="left_inner">
<li><a href="#">Login</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Description</a></li>
<li><a href="#">Contact me</a></li>
</ul>
</div>
</div>
<div class="midcol">
Center
</div>
<div class="rightcol">
Right Column
</div>
</div>
<div class="footer">Designed By <a href="">Me</a></div>
</div>
</body>
</html>
因为我要创建一个动态网站,所以我想把这个template.html 分成index.php、header.php、navbar.php、home.php 和footer.php。所以我做了以下事情:
索引.php
<?php
include("includes/header.html");
include("includes/navbar.html");
include("includes/home.html");
include("includes/footer.html");
?>
header.html
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Application</title>
<link href="CSS/layout.css" rel="stylesheet" />
<script src=""></script>
</head>
<body>
<div class="wrapper">
<div class="header">
<!--<div class="header_left"></div>
<div class="header_right"> -->
<h3>Application</h3>
<h4>****Project ****</h4>
</div>
导航栏.html
<div class="navbar">
<ul class="mainnavbar">
<li><a href="#">Home</a></li>
<li><a href="login.html">About</a></li>
<li><a href="#">Description</a></li>
<li><a href="#">Contact Me</a></li>
</ul>
</div>
主页.html
<div class="mainbody">
<div class="leftcol">
<div class="left_navbar">
<ul class="left_inner">
<li><a href="#">Login</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Description</a></li>
<li><a href="#">Contact me</a></li>
</ul>
</div>
</div>
<div class="midcol">
Center
</div>
<div class="rightcol">
Right Column
</div>
</div>
页脚.html
<div class="footer">Designed By <a href="">me</a></div>
</div>
</body>
</html>
我将这些文件放在一个名为 include 的文件夹中。我只是将文件 template.html 分成 4 个 html 文件,然后从 index.php 中调用它们,但是当我在浏览器中运行 index.php 时,我只是得到一个白页。有什么遗漏吗?