php - Wamp 服务器不显示 css

标签 php html css codeigniter

我在一个 .css 文件中创建了两个 div,然后我在一个 php 头文件中链接了那个 .css 文件,就像这样

<!DOCTYPE html>

<html>
<head>

<link rel="stylesheet" href="css/headercss.css" type="text/css" media="screen" title="default">

</head>


<body bgcolor="#F0F0F0">

<div class="div_menu">
<h1> asdasd </h1>
</div>

<div class="div_main">

这是css文件

@charset "utf-8";
/* CSS Document */


.div_menu{
background-image:url('table_header_options.jpg');
width:70%;
margin:auto;
height:50px;
}

.div_main{
background-color:#FFF;
margin:auto;
width:69.75%;
height:800px;
margin-top:15px;

border-width:1px;
border-style:solid;
border-bottom-color:#ddd;
border-right-color:#ddd;
border-top-color:#aaa;
border-left-color:#aaa;
border-radius:10px;
-moz-border-radius:10px;
-webkit-border-radius:10px;
-moz-box-shadow: 10px 10px 5px #888;
-webkit-box-shadow: 10px 10px 5px #888;
box-shadow: 10px 10px 5px #888;
}

我确信目录没有任何问题,因为当我仅使用谷歌浏览器运行 php 文件时一切正常,但当我尝试通过 wamp 服务器从本地主机打开它时,除了 h1 标记外,一切都消失了。

任何帮助将不胜感激!

最佳答案

您需要确保从正确的相对位置调用 css。

由于这是一个 PHP 头文件,我假设您从不同的地方调用它(例如 //about/otherfolder 等)。

问题是您当前的代码将在 current 文件夹中寻找 css 文件夹,而不是它实际所在的顶层文件夹。

因此:

<link rel="stylesheet" href="/css/headercss.css" type="text/css" media="screen" title="default">

注意 /css/headercss.css 的绝对定位- /在前面的意思是“从上面”。

编辑:事实证明 OP 正在使用 CodeIgniter,应该重新提交他的问题标记为这样。

关于php - Wamp 服务器不显示 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11854451/

相关文章:

html - 使用 bootstrap 如何在不使用绝对或负左边距的情况下制作位于导航容器外部的 div

PHP:调用字符串上的成员函数 contains()

CSS 替代 HTML <center>

php - 使用 NULL 值变量从 PHP 将 NULL 值插入 MySQL

php无法无错误上传大文件

html - 滚动 float

html - 为什么 img 标签会超出其宽度?

html - 垂直对齐 float 元素

php - Yii2 - 如何列出文件夹内的文件

php - 多版本哈希密码