doutuo1908 2017-04-13 06:40
浏览 64
已采纳

Bootstrap css不使用codeigniter

I have created a controller in codeigniter.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');


class Main extends CI_Controller{

    public function login(){

        $this->load->view('view_login');
    }
}

and Below is my view.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Voyager</title>
        <link href="../../assets/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
        <link href="../../assets/css/bootstrap.css" rel="stylesheet" type="text/css"/>

</head>
<body>

    <table>
        <tr>
            <td>
                <div class="panel panel-heading">
                    This is Heading
                </div>
                <input type="submit" class="btn btn-primary">
            </td>    
        </tr>

    </table>    

    <p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds. <?php echo  (ENVIRONMENT === 'development') ?  'CodeIgniter Version <strong>' . CI_VERSION . '</strong>' : '' ?></p>
        <script src="../../assets/js/bootstrap.min.js" type="text/javascript"></script>
        <script src="../../assets/js/jquery-3.2.1.min.js" type="text/javascript"></script>
        <script src="../../assets/js/bootstrap.js" type="text/javascript"></script>


</body>
</html>

With this Code, Page is rendered but CSS is not applied.

Am I missing something?

Another question which I have is Why do we need helper, I have added code to autoload helper. Why do we need that?

  • 写回答

3条回答 默认 最新

  • dongshao4207 2017-04-13 06:50
    关注

    You have to add full path to get CSS styles

    CodeIgniter is a MVC structure and file actually call from controller so we can't get actual path so we have to add Full Url of any file so we can not get any type of issue or error.

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

    And also change your config/config.php file

    $config['base_url'] = 'http://localhost/yoursitefolder'; // you can set your working url
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?