CodeIgniter Forums
How to add css styles - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: How to add css styles (/showthread.php?tid=9218)

Pages: 1 2 3


How to add css styles - El Forum - 06-17-2008

[eluser]szulcseban[/eluser]
Hello!
I'm a newbie in Code Igniter.
How add css styles in CI??
Regards


How to add css styles - El Forum - 06-17-2008

[eluser]AgentPhoenix[/eluser]
You can just add the styles to the HEAD of your view file, or if you want to use those same styles across a bunch of pages, just include a CSS file in your view.


How to add css styles - El Forum - 06-17-2008

[eluser]wiredesignz[/eluser]
For a newbie I suggest using the the same method as you have in the past.

Use <style> in html or include a style sheet in your view <head>.

EDIT:
Oops too slow. Wink


How to add css styles - El Forum - 06-17-2008

[eluser]szulcseban[/eluser]
Well, I've just added to my view that link to css: <link rel="stylesheet" href="style.css" type="text/css" /> but CI didn't recognize this stylesheet.


How to add css styles - El Forum - 06-17-2008

[eluser]xwero[/eluser]
You can add a base tag to your html or you can use an absolute url.


How to add css styles - El Forum - 06-17-2008

[eluser]szulcseban[/eluser]
Thanks xwero, absolute url run.


How to add css styles - El Forum - 06-17-2008

[eluser]AgentPhoenix[/eluser]
Assuming you put the CSS file in your views folder, you could do something like

Code:
<link rel="stylesheet" href="<?=base_url();?>/system/application/views/style.css" type="text/css" />



How to add css styles - El Forum - 06-17-2008

[eluser]szulcseban[/eluser]
Thanks, the other way is to use HTML Helper link_tag().
CI seems to be very nice framework Wink


How to add css styles - El Forum - 06-17-2008

[eluser]AgentPhoenix[/eluser]
Nice. I actually didn't know about the link_tag() method. I'm gonna have to do some more digging around the user guide. Smile


How to add css styles - El Forum - 06-17-2008

[eluser]webdezzo[/eluser]
We usually create our images, css, flash, js folders in the root of our install, right along side of the main index.php file that loads up CI. This makes linking to assets fairly easy (images/logo.gif) etc, the only thing you have to watch out for is if you are in another sub of a controller, ie, domain.com/mycontroller/mysub, then it will break the paths, therefore, It's usually a good idea to include the path to the image, like (<?= base_url() ?>images/logo.gif ... then you don't have to worry about it from anywhere in your app.