max51888 发表于 2012-12-30 21:54:39

css文件加载时的路径问题

本帖最后由 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

楼上正解

max51888 发表于 2012-12-31 09:01:36

已经找到一个方法了,谢谢了。在前面添加这句代码:<?=base_url()?>
页: [1]
查看完整版本: css文件加载时的路径问题