Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter PHP stylesheet link. HOW?

I'm using xampp for my php. And I have download a code igniter and save it on my htdocs. I already made a databasing and a sample page. My only problem is how can I link my css. Where should I save my style.css? How can I call my style.css?

<link rel="stylesheet" href="<? base_url(); ?>stylesheet/style.css" type="text/css" media="screen"/>

I have this but still have a problem. Is there a step by step on how to link a css?

Thank You.

like image 404
Jorge Avatar asked Apr 30 '10 14:04

Jorge


2 Answers

Put your CSS wherever you’d like, then target that url.

Try putting it in the folder ‘/css/test.css’ for instance ‘/’ being the root of your site, not your CI install.

From CI, you can then call it with

<?= link_tag(base_url().'css/test.css'); ?>

That should generate the following code

<link href="http://yoursite.com/css/test.css" rel="stylesheet" type="text/css" />

If you’re having trouble targetin the CSS, the easiest way to find out where your script is trying to call it, is to look in your web pages source output. You’ll see exactly where CI thinks it’s located.

like image 53
Sarfraz Avatar answered Sep 18 '22 12:09

Sarfraz


You can put your stylesheet anywhere really - it's just a matter of getting your directory to it correctly. The code you posted is going to look in your main directory (the folder with the license, system, user_guide, etc. It's going to a look for a folder called 'stylesheet', and then for style.css.

Make sure that you have your stylesheet in there.

like image 34
DexterW Avatar answered Sep 18 '22 12:09

DexterW