|
控制器如下:
<?php
class Start extends CI_Controller {
var $base;
var $css;
function indext()
{
$this->base = $this->config->item('base_url');
$this->css = $this->config->item('css');
}
function hello($name)
{
$data['css'] = $this->config->item('css');
$data['base'] =$this->config->item('base_url') ;
$data['mytitle'] = 'Welcome to this site';
$data['mytext'] = "Hello, $name, now we're getting dynamic!";
$this->load->view('testview', $data);
}
}
?>
视图testview.php如下
<html>i
<head>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'http:\/\/www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns="http:\/\/www.w3.org/1999/xhtml">
<title>Web test Site</title>
<base href="<?php echo "$base"; ?>">
<link rel="stylesheet" type="text/css" href="$base/$css">
</head>
<body>
<h1><?php echo $mytitle; ?> </h1>
<p class="test"> <?php echo $mytext; ?> </p>
<?php echo $base;?>
<?php echo "$css";?>
</body>
</html>
css文件放在ci目录下
h1 {
margin: 5px;
padding-left: 10px;
padding-right: 10px;
background: #ffffff;
color: blue;
width: 100%;
font-size: 36px;
}
.test{
margin: 5px;
padding-left: 10px;
padding-right: 10px;
background: #ffffff;
color: red;
width: 100%;
font-size: 36px;
}
为什么其他都可以显示,就是css样式加载不了? |
|