CodeIgniter Forums
linking images from css - 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: linking images from css (/showthread.php?tid=32068)



linking images from css - El Forum - 07-12-2010

[eluser]Unknown[/eluser]
hi,

my css files are stored in /css/960/example.css and how do i link images from css so they can be found each time? for example for background-image:url(images/image.gif)

the problem is if i have some deep page like http://domain.com/news/article/123/full-view the the image is not properly linked because the path is wrong...

remember that i don't want to use absolute paths only relative ones..


linking images from css - El Forum - 07-12-2010

[eluser]Tripic[/eluser]
have you tryed link tag in html helper?
http://ellislab.com/codeigniter/user-guide/helpers/html_helper.html#link_tag


linking images from css - El Forum - 07-12-2010

[eluser]Unknown[/eluser]
[quote author="Tripic" date="1278974827"]have you tryed link tag in html helper?
http://ellislab.com/codeigniter/user-guide/helpers/html_helper.html#link_tag[/quote]

i know how to load the css but how do i get proper image url's from INSIDE the CSS?


linking images from css - El Forum - 07-12-2010

[eluser]Brandon Beasley[/eluser]
Is this what you are asking?

Code:
<img src="&lt;?=base_url() ?&gt;images/test.png" alt="test PNG" />

base_url() will be pulled from settings in config.php


linking images from css - El Forum - 07-12-2010

[eluser]danmontgomery[/eluser]
In a .css paths are always relative to the css file.

in /css/960/example.css,

Code:
background-image: url('images/image.jpg');

Would be looking for /css/960/images/image.jpg


linking images from css - El Forum - 07-12-2010

[eluser]InsiteFX[/eluser]
Code:
css
images

background-image: url('../images/image.jpg');

InsiteFX