2013-08-20 91 views
0

我在嘗試加載模板/ header.php和footer.php中的css時遇到問題,並在執行此操作時遇到問題。我codeignitor應用無法在codeignitor平臺中加載css

結構

-application 
-views 

-- css (folder) 
    --- style.css 
-- template (folder) 
    ---header.php 

在header.php中我使用的是以下行來加載CSS

<style> @import url('<?=base_url()?>css/style.css'); </style> 

在Web控制檯,我把它看作

GET http://localhost/groce/css/style.css [HTTP/1.1 404 Not Found 1ms] 

其中groce是我的應用程序的名稱

+0

把css文件夾在您的項目其良好的實踐 –

+0

根目錄下把你的index.php和任何CSS,JS和圖片文件夾爲「公共」目錄下,並說你的網站根 – Pattle

回答

1

試試這個:

<link rel="stylesheet" href="<?=site_url('css/style.css');?>" type="text/css"/> 

而你需要的應用程序結構是這樣的:

-application 
-css 
-system 
index.php 
.htaccess 

還需要添加CSS文件重寫條件.htaccess

RewriteCond $1 !^(index\.php|css) 
0

嘗試正確的: :

<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/style.css"> 

結構::

-application 
-css 
-system