How to include CSS file in CodeIgniter?

I have a resource folder in the root directory where the application folder exists. I now have assets related to the application.

Now when I tried to open http://localhost/CodeIgniter/assets/css/bootstrap.min.css on a web page, it does not work.

Can someone help me how can I make it work.

In the solution, I found that writing this line in the configuration file will work, but it does not work either by making this change.

 $config['base_url'] = 'http://localhost/CodeIgniter/'; 

Now please tell me how to load a CSS file in CI.

: -

I did something wrong in my codeigniter project. I download it again and again I try this thing without working anything.

Thanks to all the guys. you save my time.

+8
html css php codeigniter
source share
3 answers

determine the common css that was used. Open "config.php" in the CodeIgniter \ system \ application \ config directory.

 $config['css'] = 'mystyles.css'; 

Create a file called mystyles.css inside the root application: \ CodeIgniter.

 $this->load->helper('url'); $data['css'] = $this->config->item('css'); 

You can download css as such pages.

+2
source share

In the constant .php:

 define('URL','http://localhost/CodeIgniter/'); define('IMG',URL.'assets/img/'); define('CSS',URL.'assets/css/'); define('JS',URL.'assets/js/'); 

In the config.php file:

 $config['base_url'] = URL; 

In sight:

 <link rel="stylesheet" href="<?php echo(CSS.'bootstrap.min.css'); ?>"> 

Hope this helps.

+13
source share

Add the line below to your controller action /application/controllers/yourController.php

 $this->load->helper('url'); 

Then add the line below to your view file header tag.

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

Assuming you have assets / css / folder created in your application directory.

 <path to your app folder>/assets/css 
+1
source share

All Articles