Set Base URL to background image path in External CSS - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Set Base URL to background image path in External CSS (/showthread.php?tid=70957) Pages:
1
2
|
Set Base URL to background image path in External CSS - sanjaya - 06-21-2018 Any one can help me to add base url to my background image path in my external css. My code like below. PHP Code: aside.main-sidebar{ RE: Set Base URL to background image path in External CSS - jreklund - 06-22-2018 And why do you need to do it? I got everything setup with absolute paths (like above) and some script use relative paths instead, like Jquery UI. RE: Set Base URL to background image path in External CSS - Pertti - 06-22-2018 Assuming you are developing on one machine, and deploying to somewhere else, so the domain names will be different on all the instances, best solution usually means using relative paths. You know where the CSS is, so you can go from there, replace it with ../../ui/assets/img for example. Remember not to start with / as this will point to your base domain. If you absolutely must do absolute paths in CSS file, you could set up a controller that outputs CSS file format text, however 99% of the time that's just over-complicating something that can be done with very straight forward solution. RE: Set Base URL to background image path in External CSS - sanjaya - 06-22-2018 (06-22-2018, 01:24 AM)Pertti Wrote: Assuming you are developing on one machine, and deploying to somewhere else, so the domain names will be different on all the instances, best solution usually means using relative paths. RE: Set Base URL to background image path in External CSS - Pertti - 06-22-2018 (06-22-2018, 04:20 AM)sanjaya Wrote: I have add it like below. But it not work It was just an example, but if you tell me in which folder your CSS is, I can probably help to piece it together. RE: Set Base URL to background image path in External CSS - sanjaya - 06-22-2018 (06-22-2018, 04:24 AM)Pertti Wrote:(06-22-2018, 04:20 AM)sanjaya Wrote: I have add it like below. But it not work It's in http://localhost/projects/charity/assets/dist/css/admin.css RE: Set Base URL to background image path in External CSS - Pertti - 06-22-2018 Ok so you want to go from: /projects/charity/assets/dist/css/admin.css to: /ui/assets/img/bg4.jpg So you have to go up 5 directories, then back in, which would make final URL: ../../../../../ui/assets/img/bg4.jpg RE: Set Base URL to background image path in External CSS - sanjaya - 06-25-2018 (06-22-2018, 06:30 AM)Pertti Wrote: Ok so you want to go from: It's not work... RE: Set Base URL to background image path in External CSS - Pertti - 06-25-2018 (06-25-2018, 12:11 AM)sanjaya Wrote: It's not work... Based on what you provided earlier, should work but what's the full URL, with domain, to the image? RE: Set Base URL to background image path in External CSS - sanjaya - 06-25-2018 (06-25-2018, 12:31 AM)Pertti Wrote:(06-25-2018, 12:11 AM)sanjaya Wrote: It's not work... This is directory: http://sghapps.tk/ui/assets/img/bg4.jpg |