【发布时间】:2019-02-03 23:52:53
【问题描述】:
我有一个使用 php 的项目;我有一个包含文件夹,其中有我的 header.php 和 footer.php 我的样式表和其他样式表链接在 header.php 的 head 标签中
我有另一个名为calculator的文件夹,现在我在calculator文件夹的索引文件中包含了header.php和footer.php,它可以工作,但是css没有生效
这是计算器索引文件中的代码
<?php
include '../include/header.php';
?>
<form action="" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="exampleFormControlInput1">Name of Share</label>
<input type="text" class="form-control" id="exampleFormControlInput1">
</div>
<div class="form-group">
<label for="exampleFormControlInput1">Number of Shares</label>
<input type="text" class="form-control" id="exampleFormControlInput1">
</div>
<div class="form-group">
<label for="exampleFormControlInput1">Purchase Price</label>
<input type="text" class="form-control" id="exampleFormControlInput1">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<?php
include '../include/footer.php';
?>
请指教
【问题讨论】:
-
看看
$_SERVER['DOCUMENT_ROOT'] -
您的 css 文件路径(您在 header.php 中声明它对吗?)不正确。
-
在样式的 href
<link href="/css/styles.css"..>中使用斜线/。这将始终从服务器的(文档)根目录加载。