[英]How can I include the CSS file in CodeIgniter?
I have make a assets folder in root directory where application folder exist. 我在根目录中创建了一个资源文件夹,其中存在应用程序文件夹 now I have assets sibling to application. 现在我有资产兄弟申请。
Now when I tried to open http://localhost/CodeIgniter/assets/css/bootstrap.min.css
in web-page it's not working. 现在,当我尝试在网页中打开http://localhost/CodeIgniter/assets/css/bootstrap.min.css
,它无法正常工作。
Do someone can help me how I can got it worked. 有人可以帮助我如何使它工作。
In a solution I found that writing this line in config file will work but it's not work either by doing this change. 在一个解决方案中,我发现在配置文件中写这一行是可行的,但是通过这种改变它也不起作用。
$config['base_url'] = 'http://localhost/CodeIgniter/';
Now please some guideline me how to load CSS file in CI. 现在请一些指导我如何在CI中加载CSS文件。
solution :- 解决方案: -
I have done something wrong in my codeigniter project. 我在codeigniter项目中做错了。 I download it again and try these thing again, without anything it's working. 我再次下载并重新尝试这些东西,没有任何工作。
thanks you all of guys. 谢谢你们所有人 you save my time. 你节省了我的时间。
In constant.php: 在constant.php中:
define('URL','http://localhost/CodeIgniter/');
define('IMG',URL.'assets/img/');
define('CSS',URL.'assets/css/');
define('JS',URL.'assets/js/');
In config.php: 在config.php中:
$config['base_url'] = URL;
In view: 在视图中:
<link rel="stylesheet" href="<?php echo(CSS.'bootstrap.min.css'); ?>">
Hope that helps somewhat. 希望有所帮助。
define general css that used. 定义使用的一般css。 Open "config.php" within directory CodeIgniter\\system\\application\\config. 在目录CodeIgniter \\ system \\ application \\ config中打开“config.php”。
$config['css'] = 'mystyles.css';
Create a file named mystyles.css within root application: \\CodeIgniter. 在根应用程序:\\ CodeIgniter中创建名为mystyles.css的文件。
$this->load->helper('url');
$data['css'] = $this->config->item('css');
You can load css in views pages like this. 您可以在这样的视图页面中加载css。
Add below line in your controller action /application/controllers/yourController.php 在控制器操作/application/controllers/yourController.php中添加以下行
$this->load->helper('url');
Then add below line to your view file's head tag. 然后在视图文件的head标记中添加以下行。
<link rel="stylesheet" type="text/css" href="<? echo base_url('assets/css/yourcssfile.css');?>" />
Assuming that you have assets/css/ folder is created in your app directory. 假设您在app目录中创建了assets / css / folder。
<path to your app folder>/assets/css
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.