Welcome Guest, Not a member yet? Register   Sign In
How to add css styles
#1

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

[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.
#3

[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
#4

[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.
#5

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

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

[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" />
#8

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

[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
#10

[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.




Theme © iAndrew 2016 - Forum software by © MyBB