如何修复php文件中的页眉和页脚

如何修复php文件中的页眉和页脚,php,css,Php,Css,我正在使用php开发一个代码。在其中,我将在另一个php文件index.php中导入两个文件header.php和footer.php。 现在我希望在水平滚动时,header.php和footer.php应该是固定的。你能告诉我密码吗。我正在使用以下代码 Header.php code here footer.php code here index.php <?php include("header.php"); ?> welcome to index file welc

我正在使用php开发一个代码。在其中,我将在另一个php文件index.php中导入两个文件header.php和footer.php。 现在我希望在水平滚动时,header.php和footer.php应该是固定的。你能告诉我密码吗。我正在使用以下代码

Header.php
 code here
footer.php
code here 
index.php

<?php include("header.php"); ?>
 welcome to index file 
 welcome to index file 
 welcome to index file 

<?php include("footer.php"); ?>
在这个文件index.php中,我希望在水平滚动时页眉和页脚应该是固定的,其他css也不应该受到干扰。

您的解决方案是可以的。 只有我建议使用这样的东西:

<div id="header">
<?PHP include_once('header.php');?>
</div>
<div id="wrap">
here is my html content
</div>
<div id="footer">
<?PHP include_once('foo.php');?>
</div>
使用include_一次是为了不重复包含某些文件 使用好的css可以获得出色的布局

试试这个

 <div id="header">
    <?PHP include_once('header.php');?>
    </div>
    <div id="wrap">
    welcome to index file
    </div>
    <div id="footer">
    <?PHP include_once('foo.php');?>
    </div>

使用HTML5并使用include_一次


在css中,只需添加以下属性:
位置:固定;这应该可以解决问题。

首先,你需要了解PHP与之无关。它是一个CSS部分。如果你有问题,请给出解决方案。你能为我推荐页眉、页脚和wrap div的CSS吗also@adeshsingh我用css添加了一个答案。如果您有进一步的疑问,我可以帮助您滚动是工作到顶部和底部,但我想滚动应该从下面的页眉和页脚顶部检查,我的网站之一,尝试的html和css代码的layoutheader和页脚是固定的,但滚动是工作到顶部和底部
#header{position:fixed;top:0px;}
#footer{position:fixed;bottom:0px;}
header.php 
<div id ="header"></div><div id="content">
footer.php
</div><div id="footer"></div>

index.php
<?PHP include_once('header.php');?>
 content here.,
<?PHP include_once('footer.php');?>
<header>
<?PHP include_once('header.php');?>
</header>
<div id="wrap">
here is my html content
</div>
<footer>
<?PHP include_once('foo.php');?>
</footer>
html,body{
    margin:0;padding:0;
}
header{
    background:Green;
    height:50px;
}
footer{
    position:absolute;
    width:100%;
    bottom:0;
    background:Red;
    height:50px;
}