我只是在 PHP 中练习一些东西,遇到了一个问题。
我正在使用 PHP 的“Include”功能将多个页面链接到单个 index.php 页面(正如我所读到的那样,它使大型网站更易于管理且易于更新。
我已经创建了外部 CSS 文件(总共 3 个,一个用于导航、页面样式和包装器内容)和一些外部 JS 文件,这些文件都已链接到名为 head.php 的 PHP 文档。 (下面是head.php的内容)
服务器将首先显示的主页将是“index.php”,因此对于此页面,我将链接所有其他部分,这些部分将全部组合在一起以创建单个页面。 (下面是index.php的内容)
我的问题是在 head 和 footer php include 行之间我创建了一个名为“wrapper”的 div(样式已经应用到一个名为“style.css”的外部 CSS 表,它在 head.php 中链接)(请查看底部的 style.css 内容)我认为当我在浏览器中查看 index.php 时(我使用的是 XAMPP)应该在页面上显示包装器,但是我看不到包装器,我只是继续只看导航栏,我觉得这很奇怪,因为我可以使用 <h1>
和 <p>
index.php 中的标签由 php 包含的 head.php 页面进行外部样式设置。
请查看下面提到的所有页面的代码,我不确定我在这里做错了什么。谢谢
下面是 HEAD.PHP:
<!DOCTYPE HTML>
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="css/navigation.css">
<link rel="stylesheet" type="text/css" href="css/sitestyle.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"> </script>
<script type="text/javascript" src="responsee.js"></script>
<link rel="stylesheet" type="text/css" href="engine1//style.css" media="screen" />
<script type="text/javascript" src="engine1//jquery.js"></script>
<script type="text/javascript" src="drop.js"></script>
<script type="text/javascript" src="https://apis.google.com/js/platform.js"></script>
<title>MC SMM | Home</title>
</HEAD>
下面是 STYLE.CSS:
#wrapepr {
background-color:black;
width:1000px;
height:1000px;
margin:0 auto;
}
下面是 INDEX.PHP:
<?php include('segments/head.php'); ?>
<?php include('segments/facebookjs.php'); ?>
<?php include('segments/homenav.php'); ?>
<div id="wrapper"></div>
<?php include('segments/headbottom.php'); ?>
最佳答案
您在样式表中拼错了包装器 ID 名称:
“#wrapepr”
应该变成:
#wrapper
关于javascript - 使用 PHP 'Include' 将多个页面链接到单个 index.php 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25233606/