【问题标题】:Style CSS does not With CodeIgniter - Baseurl样式 CSS 不使用 CodeIgniter - Baseurl
【发布时间】:2013-04-13 16:24:22
【问题描述】:
这个问题已经被问过好几次了,但还没有找到适合我的项目的正确答案。
我喜欢的 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,但它对我不起作用。
那么问题是什么?有人可以帮忙吗?
【问题讨论】:
标签:
css
image
codeigniter
base-url
【解决方案1】:
你的结构应该是这样的
myproject
application
assets
css
style.css
system
config/autoload.php 中的自动加载 url 助手
$autoload['helper'] = array('url');
现在
<link href = '<?php echo base_url()?>/assets/css/style.css'>
这应该可行。如果您使用的是 linux,请确保您的拼写正确并查看 casd 敏感问题。
【解决方案2】:
你的 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() 设置为空。如果您还没有上传到虚拟主机/服务器。
【解决方案3】:
Try this once -
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/style.css" />
【解决方案4】:
您可以像这样放置自定义 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>