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条)

报告相同问题?

悬赏问题

  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择