问题
I have this code
<link href = "<?php echo base_url(); ?>css/style.css” rel=”stylesheet" type="text/css" />
which supposed to load the style.css
from the css folder. The echo base_url()
itself works.
I also have autoloaded the url helper
, so i really don't see the problem here, but it still doesn't load.
回答1:
Also make sure that the directory is not "blocked" by the .htaccess
file, if you are using it to remove index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Personally I would move the css diectory into an assets directory:
/assets/css
/assets/js
/assets/img
回答2:
the default location for css files is the same level as the application i.e.,
/css
/application
Check the path as has been suggested.
回答3:
View the source of the page and click the css file link, if it 404s then check your .htaccess file and make sure that that directory is available!
回答4:
try including the relative link in the function like on the user_guide
< link href = " < ? php echo base_url('css/style.css') ; ? >” rel=”stylesheet" type="text/css"/>
回答5:
application/views/globals/css/style.css" type="text/css" media="screen" />
or whatever your folders srtucture is!
来源:https://stackoverflow.com/questions/11470171/css-not-loading-in-codeigniter