How to make style.css works well in codeigniter?

Member

by darion , in category: PHP Frameworks , a month ago

How to make style.css works well in codeigniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by jasen , a month ago

@darion 

To make style.css work well in CodeIgniter, follow these steps:

  1. Place your style.css file in the "assets" directory within your CodeIgniter project. If the "assets" directory does not exist, create one in the root directory of your project.
  2. In your CodeIgniter controller, load the URL helper by adding the following line of code in the constructor method: $this->load->helper('url');
  3. In your view file, link your style.css file by using the base_url() function to specify the path to the "assets" directory.
  4. Make sure you have properly configured your CodeIgniter project to set up the base URL in the config.php file. In the application/config/config.php file, set the base URL to the root directory of your project: $config['base_url'] = 'http://localhost/yourproject/';
  5. Finally, make sure your.htaccess file is correctly configured to remove index.php from the URL. This will ensure that the path to your CSS file is correctly resolved.


By following these steps, you can make your style.css file work well in CodeIgniter and render the styles properly in your views.