新手求助 图片、js、jq和css显示不了
为什么图片放在views底下就不显示 放在index .php同目录下就可以显示呢???代码:<img src="./images/index.gif" width="200" height="50" /> 图片JSCSS等最好使用绝对路径
<img src="<?php echo $base?>application/views/images/index.gif" width="200" height="50" /> wx2650 发表于 2012-8-11 13:04 static/image/common/back.gif
图片JSCSS等最好使用绝对路径
还是不行哦。。 每次插入图片都要写base_url()有没有别的方法 统一放到一个根目录里就可以了,最好用绝对路径 本帖最后由 wx2650 于 2012-8-12 00:56 编辑
<head>
<title>博客列表</title>
<base href="http://127.0.0.1/Blog/" />
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<!-- CuFon: Enables smooth pretty custom font rendering. 100% SEO friendly. To disable, remove this section -->
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/arial.js"></script>
<script type="text/javascript" src="js/cuf_run.js"></script>
</head>
如上
可以看到head中还有很多js和css
上面的JS写的都是相对路径,这个路径是相对于“http://127.0.0.1/Blog/" 来说的
相当于
<link rel="stylesheet" type="text/css" href="http://127.0.0.1/Blog/style.css" />
<script type="text/javascript" src="http://127.0.0.1/Blog/js/arial.js"></script>
因此只要写一个
<base href="<?php echo $base_url ?>" />
其他的图片或者JS就不用写 $base_url了
你还可以新建一个视图来存储“<!DOCTYPE ”到“</head>”之间的内容
而后,每次新建一个视图时,就只要写
<?php $this->load->view('header');?>
<body>
<!-- web content -->
</body>
</html>
就可以了
学会使用firebug吧
路径问题
页:
[1]