开发者

loading multiple css, images and js file in CodeIgniter

开发者 https://www.devze.com 2023-03-06 09:07 出处:网络
I have a three different folders (css, js, images)placed where the system, application, user_guide folders live.. Now I am trying to include those files in my header_view.php like below:

I have a three different folders (css, js, images)placed where the system, application, user_guide folders live.. Now I am trying to include those files in my header_view.php like below:

<link rel="stylesheet" href="<开发者_开发技巧?php echo base_url()?>/css/styles.css" type="text/css" media="screen">

<link rel="stylesheet" href="<?php echo base_url()?>/css/layout.css" type="text/css" media="screen">

Then in my view file I am including the header file like this

$this->load->view('header_view');

None of the css styles are showing..

Can someone please help me with this? thanks alot...


The obvious answer is to look at the HTML source, and visit the href that's been output by CI. It'll be something like http://mysite/com/css/styles.css

Visit that URL; if the CSS loads, the problem is elsewhere. If the CSS file does not load, then it is in the wrong directory.

Your .htaccess may also be rewriting the CSS request.

Your rule may have to look something like:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

to prevent CSS files from being rewritten.


I would use something like this to load them

<?php echo link_tag('css/reset.css'); ?>
<?php echo link_tag('css/main.css'); ?>

If your CSS files and media files are in the root like they should be, get rid of the first "/"

It should be

css/styles.css

Your css, media files and js files should live under "public_html"

0

精彩评论

暂无评论...
验证码 换一张
取 消