2016-02-12 115 views
-3

我在Codeigniter中有這個代碼文件,但是URL方法不起作用,所以我在這裏看不到問題。Css在Codeigniter框架中不加載

<?= link_tag('asstes/css/bootstrap.min.css') ?> 通過助手$this->load->helper('html');

我在做什麼錯負荷?

+0

試試這種方式: - base_url('path/to/stylesheet.css'); –

+0

你是如何去嘗試我的答案的 – user4419336

回答

0

您有一個錯誤在你的路徑字符串

asstes ---> assets 

我覺得這是更好地寫自己的幫手添加資源(JS,CSS ...)

0

笨3個版本只需檢查您的base_url是否已設置,因爲有些空白會導致鏈接無法正常工作。

$config['base_url'] = 'http://localhost/your-project/';  

控制器例如:的welcome.php

<?php 

class Welcome extends CI_Controller { 

    public function __construct() { 
    parent::__construct(); 

     $this->load->helper('html'); 
    } 

    public function index() { 

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

    } 

} 

或自動加載HTML輔助

$autoload['helper'] = array('url', 'html'); 

在你的腦袋上標記視圖link_tag guide

<html> 
<head> 
<?php echo link_tag('assets/css/bootstrap.css');?> 
</head> 

文件夾例

application 

assets 

system 

index.php