css not loading in codeigniter

ⅰ亾dé卋堺 提交于 2019-12-22 12:39:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!