如何在codeigniter中加载css [英] How to load css in codeigniter
问题描述
我是新的codeigniter,我使用v.2.12。我尝试从外部文件加载css时收到错误。
I am new to codeigniter, and I am using v.2.12. I am getting an error when I try to load the css from the external file.
我在应用程序文件夹中创建css文件夹。我在all.css的名称中创建css文件。
I create the css folder inside the application folder. And I create the css file in the name of all.css.
在视图文件中,我使用以下代码链接css文件。
In the view file I use the following code to link the css file.
<link rel="stylesheet" type="text/css" href="<? echo base_url();?>css/all.css">
但是css文件未加载。我收到404错误。这是我的配置设置:
But the css file is not loading. I'm getting 404 error. Here is my configuration settings:
$config['base_url'] = 'http://webscarlets.com/ci/index.php';
$config['index_page'] = 'index.php';
网站链接:http://webscarlets.com/ci/index.php/welcome 。
推荐答案
函数 base_url()应该返回基本路径(不带index.php)
The function base_url() should return the base path (without index.php)
您可以通过添加一个反斜杠来修复它:
You may fix it by adding a backslash like:
<link rel="stylesheet" type="text/css" href="<? echo base_url();?>/css/all.css">
或从您的配置中删除index.php:
or remove the index.php from your config:
$config['base_url'] = 'http://webscarlets.com/ci/';
这篇关于如何在codeigniter中加载css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!