对特定页面使用包含和样式表? [英] Using includes and stylesheets for a specific page?

查看:109
本文介绍了对特定页面使用包含和样式表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要为我的网站使用includes,为
设置header,footer,nav等。在标题中,我将DOCTYPE添加到 / head> 标签。

I was about to use includes for my websites, setting up includes for the header, footer, nav, etc. In the header I added the DOCTYPE to the end of the </head> tag.

如果我这样做,我如何为一个特定页面添加样式表页面是在包括?

If I do it this way, how would I add a stylesheet just for one specific page if the head of the page is in a include?

推荐答案

有很多种方法来做这一个将包含头php文件

well there are alot of various ways to do this one would in the included header php file

添加一个变量

就像这样

<?=@$css;?>

,然后在包含它的文件中将css变量定义为要包含的任何内容



and then in the file that includes it define the css variable to whatever you want to be included

$css = 'something';

include(header.php);

如果这是您的header.php

if this is your header.php

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?=@$css;?>
</head>

这是您的index.php

and this is your index.php

$css= '<link href="style.css" rel="stylesheet" type="text/css" />';
include('header.php');

这篇关于对特定页面使用包含和样式表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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