Working with css, images, and jQuery in CodeIgniter

I spent a lot of time for seeking an appropriate solution to use external stylesheets in CodeIgniter. If you are not patient, I think you will give up the racing.

Here is the silver point I have found. It can be described briefly as follows:

Typically, create an “assets” directory for files that need to be accessed like the following:

-application
-system
-assets
—images
—scripts
—styles

Pay attention to that all file references are usually based upon the index.php file. This means you would access a css file via “assets/styles/mystyle.css”

When I want to use a stylesheet and javascript links, I usually do the following:

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

You could try several instructions as follows:

http://stackoverflow.com/questions/5450095/codeigniter-simple-base-url-question

http://ellislab.com/forums/viewthread/62527/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.