CodeIgniter Forums
Unable to get css on page - 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: Unable to get css on page (/showthread.php?tid=63121)



Unable to get css on page - kartikmehra - 09-28-2015

Hi

I am trying to get css called in but I am getting errors .

what should I do .

pfa!!


Thanks


RE: Unable to get css on page - PaulD - 09-28-2015

You probably need to link to your files using base_url() which you can read about here: http://www.codeigniter.com/user_guide/helpers/url_helper.html#base_url

So in the head you would have for style sheets something like:

PHP Code:
<link href="<?php echo base_url('assets/bootstrap/css/bootstrap.min.css'); ?>" rel="stylesheet"

and for your footer js links something like:

PHP Code:
<script src="<?php echo base_url('assets/bootstrap/js/bootstrap.min.js'); ?>"></script

Hope that helps,

Best wishes,

Paul.


RE: Unable to get css on page - freddy - 09-28-2015

Yes you should check your js and css by using helper codeignter, if you think already did then press ctrl+u then click on css or js, don't forget to autoload url


RE: Unable to get css on page - kartikmehra - 10-01-2015

(09-28-2015, 12:35 PM)PaulD Wrote: You probably need to link to your files using base_url() which you can read about here: http://www.codeigniter.com/user_guide/helpers/url_helper.html#base_url

So in the head you would have for style sheets something like:


PHP Code:
<link href="<?php echo base_url('assets/bootstrap/css/bootstrap.min.css'); ?>" rel="stylesheet"

and for your footer js links something like:


PHP Code:
<script src="<?php echo base_url('assets/bootstrap/js/bootstrap.min.js'); ?>"></script

Hope that helps,

Best wishes,

Paul.

Thanks PaulD
its working fine now !!
Smile Smile Smile Smile


RE: Unable to get css on page - kartikmehra - 10-01-2015

Thanks freddy now its working fine !!!!


RE: Unable to get css on page - CroNiX - 10-05-2015

You could also just use an absolute url, starting with a / to start from site root:
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">


RE: Unable to get css on page - kartikmehra - 10-07-2015

(10-05-2015, 11:50 AM)CroNiX Wrote: You could also just use an absolute url, starting with a / to start from site root:
<link href="/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">

Hi,

Thanks CroNiX  I will do this as well ..