Jump to content


This topic is now archived and is closed to further replies.


CSS Not Working in Codeigniter

Recommended Posts

Hi, I created a css folder for all my styles, when i link the style on my editor i can see the style output but on the browser the style does not reflect. why is it so? what can i do to make it reflect.


thank you

Share this post

Link to post
Share on other sites

Can you show us an example.


my folder structure: application, css, images, js, system (index.php)

on my view i have a file service.php and i attached a style <link href="../../css/styles.css" rel="stylesheet" type="text/css">

on my editor, i could see the effects of my styles but when i view in browser, no effects


Share this post

Link to post
Share on other sites

What I do with CI is set up an autoloading model (config/autoload.php) with all my constants, so things like the site's name, full url paths for images, css, ans JS, and so on.



class Constants extends CI_Model {

public $CI;

 * Constructor
function __construct()
	// Call the Model constructor

	// Create an instance to CI
	$CI =& get_instance();

	// Load the settings, users & session models
	$CI->load->model('Settings_model', 'settings');
	$CI->load->model('Users_model', 'users');
	$CI->load->model('Session_model', 'user');

	// Define frequently used settings
	define('SITE_NAME', $this->get_setting('site_name'));
	define('ADMIN', 'admin/');
	define('ADMIN_URL', base_url() . 'app_path/views/' . ADMIN);
	define('FILES', '/var/www/path/to/app_path/files');  //full path to folder OUTSIDE of CMS application directory
	define('IMAGES', base_url() . 'app_path/views/images/');
	define('UPLOAD', 'app_path/views/images/');
	define('CSS', 'app_path/css/');



Then when you're using your frequent functions, you can do:

//  quick link to CSS
<?php echo link_tag(CSS . 'style.css'); ?>

// quick link for admin shtuff
<?php echo anchor(ADMIN . 'home', 'Admin Panel'); ?>

// regular linkage
<?php echo anchor('reviews/unread', 'Unread Reviews'); ?>

Share this post

Link to post
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.