在所有网页上都保留页眉和页脚吗? [英] Keeping my header and footer on all webpages?

查看:58
本文介绍了在所有网页上都保留页眉和页脚吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了网站主页的设计,现在移至其他一些页面,我希望页眉和页脚在每个页面上都显示相同.我尝试了这种基本方法,即在第二个HTML文件中链接组成我的页眉/页脚的样式表(已在首页中使用):

I've finished designing my website home page and I've now moved on the some of the other pages, I want my header and footer to appear the same on every page. I've tried this basic way of linking the same stylesheet that makes up my header/footer in the second HTML file (already used in the homepage):

<link rel="stylesheet" href="footer.css" type="text/css"/>
<link rel="stylesheet" href="header.css" type="text/css"/>

我现在知道这行不通.服务器端脚本语言是我最好的选择吗?像PHP一样?

I now understand that this isn't going to work. Would a server-side scripting language be my best bet here? Something like PHP?

如果是这样,谁能将我与如何在PHP中做到这一点的文章联系起来,我相信

If so, would anyone be able to link me with an article on how I could do this in PHP, I presume with the

 include

功能?

谢谢.

推荐答案

您当前仅链接页眉和页脚的css.如果要包含相同的html,请创建两个单独的文件header.php和footer.php,然后将它们包含在每个网页中.

You are currently only linking the css for the header and footer. If you want to include the html as the same, create two separate files header.php and footer.php, then include them into each webpage.

<?php include('path/to/header.php');?> // in the location you want the header in the page
<?php include('path/to/footer.php');?> // in the location you want the footer

从本质上讲,您是在制作零件并将其放置在所需的位置

Essentially, you're making partials and placing them wherever you want them

这篇关于在所有网页上都保留页眉和页脚吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆