Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将CSS加载到CodeIgniter中_Css_Codeigniter - Fatal编程技术网

如何将CSS加载到CodeIgniter中

如何将CSS加载到CodeIgniter中,css,codeigniter,Css,Codeigniter,我是一个全新的协同点火器。在controllers文件夹中,我创建了一个名为caller.php的文件,并在视图中创建了一个文件home.php。在视图中,我还创建了一个名为css的文件夹,并在该css文件夹中创建了style.css。在视图中,我有一些图片。这些图片也是设计的一部分。现在我想使用style.css和图片。但我不能 在caller.php中,我有: class caller extends CI_Controller { function index() {

我是一个全新的协同点火器。在controllers文件夹中,我创建了一个名为
caller.php
的文件,并在视图中创建了一个文件
home.php
。在视图中,我还创建了一个名为
css
的文件夹,并在该
css
文件夹中创建了
style.css
。在视图中,我有一些图片。这些图片也是设计的一部分。现在我想使用
style.css
和图片。但我不能

在caller.php中,我有:

class caller extends CI_Controller
{
    function index()
    {

        $this->load->view('home');  
        // What do I have to write here to load css?
    }
}
在home.php中,我有:

<html>
<head>

***------what i have to write here to load css--------***

</head>

<body>

<div id="outer">
...
</div>

</body>

</html>

***------我必须在这里写些什么来加载css--------***
...
如果需要其他配置,请说明

添加

<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/style.css">

从Oliver所说的将样式表包含在

<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/style.css">
这是假设您的样式表位于应用程序根目录下名为
css
的文件夹中

- index.php
+ system
+ application
+ css
   - style.css
请确保已启用URL帮助器以使用以下命令:。这可以通过向助手数组添加url在内部全局完成

$autoload['helper'] = array('url');

非常感谢@Malachi<代码>主目录与应用程序文件夹、系统文件夹位于同一目录中是什么意思?创建一个名为css的新目录,并将样式表放在其中当我加载它时,会显示一个空白页。当我写入时。。。。您的主要问题是文件的结构。css/目录不应该在视图/中,它应该在一个可公开访问的文件夹中。它是什么意思“从URL中删除index.php”。你能解释一下吗。是的,我的css文件位于名为cssI的文件夹的根目录中。我不知道实际的重写规则是什么?请阅读URL文档-它在那里解释了它。。。如果你没有这样做,那么它应该像奥利弗解释的那样起作用。。。。您应该将资产或css/js文件保存在CI的根目录中。
$autoload['helper'] = array('url');