用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2231|回复: 3
收起左侧

css文件加载时的路径问题

[复制链接]
发表于 2012-12-30 21:54:39 | 显示全部楼层 |阅读模式
本帖最后由 max51888 于 2012-12-30 22:41 编辑

样式文件都是建立在根目录下面:style/banner.css

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

class Home extends CI_Controller{
    function __construct()
    {
        parent::__construct();

    }
    function index(){
        $this->load->view('header');
        $this->load->view('index');
        $this->load->view('footer');
        }
    function category(){
        $this->load->view('header');
        $this->load->view('category');
        $this->load->view('footer');
    }
}
?>


header.php的文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html xmlns:wb=“http://open.weibo.com/wb”>
<head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?=$page_title;?></title>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <link href="style/banner.css" rel="stylesheet" type="text/css" />
</head>
通过http://localhost/qingpai/index.php/category 无法正常加载到css文件,不知道为什么哪位高手帮忙一下,谢谢了。



发表于 2012-12-30 23:48:16 | 显示全部楼层
相对路径无法正常显示,最好是使用绝对路径~~
发表于 2012-12-31 08:30:28 | 显示全部楼层
楼上正解
 楼主| 发表于 2012-12-31 09:01:36 | 显示全部楼层
已经找到一个方法了,谢谢了。在前面添加这句代码:<?=base_url()?>

本版积分规则