-
Notifications
You must be signed in to change notification settings - Fork 0
Category:Help::TipsAndTricks | Category:Help::CSS When using CSS in your site it is usually best to place all CSS code in separate files and include them using a link in your head tag.
[code]<link rel="stylesheet" href='css/fonts.css' type="text/css" media="screen, projection" />[/code]
With Code Igniter if you are using the [url=http://codeigniter.com/user_guide/general/urls.html]apache mod_rewrite rule[/url] to remove the index.php file from your urls you need to change the rule to allow any linked css files to be loaded. By default the rule will re-direct any url that does not include the text "index.php", "images", or "robots.txt" to your default controller.
Default rule.
[code]
RewriteEngine on
RewriteCond
Modified rule to allow loading css files.
[code]
RewriteEngine on
RewriteCond
To make for more portable code use the url helper class to link your css file.
Load the url helper class in your controller. [code]$this->load->helper('url');[/code]
Then use the url helper to link your css file. [code]<link rel="stylesheet" href='<?=base_url()?>css/reset.css' type="text/css" media="screen, projection" />[/code]
Further Reading [url=http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html]Apache Mod_Rewrite[/url] [url=http://www.regular-expressions.info/]Regular Expressions[/url]