base_url() doesn't work at CSS file...
here's my php :
<link rel="stylesheet" type="text/css" href="<?=base_url()?>css/style.css"/>
<body>
</body>
here's my css/style.css :
body {
background:#356aa0 url(<?=base_url()?>img/background.png) repeat-x;
color:#fff;
}
the text color change to white, but the image doesn't show up... if i use url(../img/background.png), it show up... but when i open url localhost/project/index.php/control/function/var1/var2, it doesn't show up...
It's Solved, Thanks every one... :]
i make php file at view folder like this :
<?php header("content-type: text/css"); ?>
body {
background:url(<?=base_url()?>img/background.png);
}
and i load the php file i just make with function at controller, and then i link it :
<link type="text/css" rel="stylesheet" href="<?=base_url()?>control/style.php"/>
It's work, Thanks guys...
You should do it like this
Structure of your files
myapp/
application/
system/
css/
img/
And in css write this
body {
background:#356aa0 url(../img/background.png) repeat-x;
color:#fff;
}
And now call it
<link rel="stylesheet" type="text/css" href="<?=base_url()?>css/style.css"/>
That is the standard way of doing it. Also your css is not dynamic so you dont have to worry about php code using in it. The structure i presented in the answer will surely use the styles correctly and load the images.