【问题标题】:Issue With Header and Footer Include页眉和页脚包含问题
【发布时间】:2015-04-03 01:17:00
【问题描述】:

我在尝试使用 php 包含显示我的固定页眉和页脚时遇到问题

这是我的 HTML

<?php include '_includes/header.php' ?>

<div class="neo__wrapper">

    <div class="neo__container">

    </div>

</div>

<?php include '_includes/footer.php' ?>

我的 SASS(用于嵌套)

*{
 margin: 0;
 padding: 0;
 text-decoration: none;
 border: 0;
 border: none;
}

html,body{ 
 width: 100%;
 height: 100%;
}

.neo__wrapper{
 width: 100%;
 height: 100%;
 margin: 0 auto;

.neo__container{
     width: 960px;
     height: 3000px;
     margin: 0 auto;
}
}

header{
 background:#ccc;
 width: 100%;
 position: fixed;
 height: 100px; 
 top: 0;
}

footer{
 background:#ccc;
 position: fixed;
 width: 100%;
 height: 50px;
 bottom: 0;
}

我只是在构建一个框架,所以我的 header.php 只是

<header></header>

我的footer.php是

<footer></footer>

基本上,我的页面应该只有一个灰色的固定页眉和页脚

【问题讨论】:

  • &lt;header&gt;&lt;?php include '_includes/header.php' ?&gt;&lt;/header&gt; 如果header.php 是您向我们展示的所有 CSS。但是,该 CSS 需要包含在 &lt;style&gt;&lt;/style&gt;&lt;head&gt;&lt;/head&gt; 或作为样式表的链接。不知道这个问题是关于什么的。
  • 您的neo__wrapper CSS 未关闭,这会在 CSS 到达页眉/页脚声明之前破坏它。 EDIT 没关系,刚刚注意到您使用的是 SASS,您确定它的编译正确吗?它对我有用。

标签: php html header include footer


【解决方案1】:

您包含一个空文件。

<head><link rel="stylesheet" type="text/css" href="MyCSSFile.css"></head>

另外,如果您在每个页面上都添加页眉和页脚,请将此代码也包含在其中。在header.php

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="MyCSSFile.css">
</head>
<body>

footer.php

<footer>
<script src="MyJavascriptFile.js"></script>
</footer>
</body>
</html>

【讨论】:

【解决方案2】:

刚刚发现这是关于 WAMP 的问题,所以 PHP 甚至一开始都没有运行

【讨论】:

    猜你喜欢
    • 2021-10-15
    • 1970-01-01
    • 2017-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-21
    • 1970-01-01
    相关资源
    最近更新 更多