php - 我的 css 使用 codeIgniter 没有正确显示

标签 php html css codeigniter

我正在尝试使用 codeigniter 在我的 table 上显示 css,但它不起作用。如果我在我的 html 的 header 部分添加了 css,它就可以工作,但问题是当我为 css 创建一个单独的文件夹时,设计不起作用。我按照在线示例正确地做到了这一点。

这是我在 View 中的代码:

<html>
<head>
<title>No title</title>
<link rel="stylesheet" href=<?php echo base_url(); ?>"css/style.css" type="text/css" media="screen" charset="utf-8">
</head>
<body>
<div id="container">
    <h4> Super pagination with CodeIgniter</h4>
    <?php echo $this->table->generate($records); ?>
    <?php echo $this->pagination->create_links(); ?>
</div>
</body>
</html>

这是我在 Controller 中的代码:

    <?php

    class Site extends CI_Controller {

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

    function index() {
        $this->load->library('pagination');
        $this->load->library('table');
        $config['base_url']='http://localhost:81/nine/index.php/site/index';
        $config['total_rows']=$this->db->get('data')->num_rows();
        $config['per_page']=1;
        $config['num_links']=20;
        $config['full_tag_open']='<div id="pagination">';
        $config['full_tag_close']='</div>';

        $this->pagination->initialize($config);
        $data['records']=$this->db->get('data', $config['per_page'], $this->uri->segment(3));
        $this->load->view('site_view', $data);
    }
}

这是自动加载:

$autoload['libraries'] = array('database');
$autoload['helper'] = array('url');

这是配置

$config['base_url'] = 'http://localhost:81/nine/';

这是数据库

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'datadb';

不知道是不是codeigniter版本的问题。我用的是2.2.0,网上是1.7.2。

enter image description here

应该是……

enter image description here

最佳答案

您的样式表链接不正确(注意 href 后的双引号):

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

关于php - 我的 css 使用 codeIgniter 没有正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24992676/

相关文章:

PHP群发邮件: One for each or one for all?

php - 如何用jquery制作表格?

css - 页面底部的页脚并在将鼠标悬停在下拉菜单上时停止移动文本

javascript - 用文本省略号在同一行显示 2 个文本

javascript - 在没有固定高度/虚拟化的情况下提高长列表的性能

php - MySQL:选择一个月的数据分为多个时间段

javascript - 调用输入类型文本的函数 - Javascript/PHP

javascript - 在 JavaScript 中制作原型(prototype)

HTML 元素在页面重新加载时移动 - 仅限 Chrome?

JQuery - 在 Javascript 中对 HTML 进行硬编码 - 有更好的方法来动态创建 dom 元素吗?