【发布时间】:2017-03-10 20:15:34
【问题描述】:
在我的网站中,我想使用 index.php 页面中的 PHP 包含行来添加页眉和页脚等重要部分。
现在,文件夹结构如下:
/index.php
/css/style.css
/includes/header.php
/includes/footer.php
请记住,我在 localhost 环境中工作。
现在我的问题是如何在 index.php 和 header.php 中正确引用我的 CSS 文件?我应该使用 config.php 文件吗?如果可能的话,我想避免使用绝对路径。
目前,我的 CSS 文件已被读取并正确显示,但是,当我进行更改时,CSS 不会显示所做的更改并保留原始未更改的文件。
index.php
<head>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<?php include 'includes/header.php';?>
<div class="container">
<div class="inner-container">
<?php include 'includes/javascript.php';?>
</div>
header.php
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<header>
<div id="logo">
<div class="logo-container">
<img src="img/final_logo_400px.png" alt="">
</div>
</div>
<nav>
<ul>
【问题讨论】:
-
到
load网页中的css文件,你需要使用html的<link />标签,而不是php的include函数; -
我应该提到我很清楚这一点,但感谢您的回复。