样式CSS没有使用CodeIgniter - Baseurl

时间:2013-04-20 09:36:46

标签: css image codeigniter base-url

这个问题已被多次询问,但未找到对我的项目有用的正确答案。

我喜欢的CSS文件

<link rel="stylesheet" type="text/css" href="assets/css/style.css"/>

css文件位于:

-main_directory
  -Application
  -Assets
    -css
       -style.css
  -System

我还尝试使用base_url href="<?php echo base_url('assets/css/style.css');?>"链接css,但它对我不起作用。

那么问题是什么?有人可以帮忙吗?

4 个答案:

答案 0 :(得分:1)

你的结构应该是这样的

myproject
  application
  assets
    css
       style.css
 system

config/autoload.php

中的自动加载网址助手
$autoload['helper'] = array('url');

现在

<link href = '<?php echo base_url()?>/assets/css/style.css'>

这应该有效。确保你的拼写正确,如果你使用linux,请查看casd敏感问题。

答案 1 :(得分:1)

你的base_url()方法配置正确吗?点击这里......

ci_app_folder/config/config.php

如果你的位于c:/ xampp / htdocs / ci_app_name

$config['base_url'] = 'localhost/ci_app_name'; //or localhost:90/ci_app_name if you had changed port

然后你可以使用这个

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

您也可以将base_url()设置为空。如果您尚未上传到网络托管/服务器。

答案 2 :(得分:0)

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

答案 3 :(得分:0)

您可以像这样放置自定义css链接:

    background-image:url(../../); moving back to the directory you want

使用CI您需要使用内联css:例如。

    <div style = background-image: url(<?php echo base_url();?>)assets/images/>
    </div>