Welcome Guest, Not a member yet? Register   Sign In
Background image in CSS - How to use base_url() in a CSS file
#1

[eluser]Juan Velandia[/eluser]
Hello, again a newbie question.

I'd like to know how can I use the base_url() whitin a CSS file? is this possible? or if I want to use a CSS style with a background I should do something like this?:

body{
padding:0px;
margin:0 auto;
background: url(http://example.com/system/application/vi...ground.jpg) 0 0 repeat-x;
}

Thanks a lot

Juan
#2

[eluser]danmontgomery[/eluser]
You should have an images folder in your css folder. All images in CSS are relative to the CSS file, so in that case you could always just use:

Code:
background: url(images/background.jpg) 0 0 repeat-x;
#3

[eluser]Juan Velandia[/eluser]
Thanks noctrum, you are right, It will surelly work!

Juan
#4

[eluser]InsiteFX[/eluser]
Here is another way of doing...

Code:
<?php
    header('Content-type: text/css');
    $img_url = base_url();
?>

.ie6hack {position:absolute; top:0px;}

* html img.logo {
    background:none;
    filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<?php echo $img_url;?>/logo.png', sizingMethod='crop');
}

Name yourname.php


Enjoy
InsiteFX
#5

[eluser]Juan Velandia[/eluser]
thanks insiteFx, i´ll check it, but i have to recognize that´s a bit confusing to me...
#6

[eluser]InsiteFX[/eluser]
Hi,

it sets the header to a css file but it is a php file with css code in it.
This is a php file that has all the css in it just make it and include it.

The ccs code is just part of my ie6 hacks.

Enjoy
InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB