Php 第二次调用Codeigniter View后背景图像消失

Php 第二次调用Codeigniter View后背景图像消失,php,css,html,codeigniter,Php,Css,Html,Codeigniter,我正在研究codeigniter。 我已经为我的主页设置了背景图像。 现在发生的事情是,当我点击主控制器时,调用了一个视图,它工作正常,但是当我试图从另一个函数中显式地调用视图时,背景图像消失,其他一切都保留在它的位置上 这是我的标题视图顶部的内容,从这里调用背景图像 <html lan="en"> <head> <style> body { background-image: url("public/img/back1.jpg");

我正在研究codeigniter。 我已经为我的主页设置了背景图像。 现在发生的事情是,当我点击主控制器时,调用了一个视图,它工作正常,但是当我试图从另一个函数中显式地调用视图时,背景图像消失,其他一切都保留在它的位置上

这是我的标题视图顶部的内容,从这里调用背景图像

<html lan="en">
<head>    
<style>
body {
    background-image: url("public/img/back1.jpg");
    background-repeat: no-repeat;
    background-position: right top;
}
</style>
每次我点击控制器时,它都可以正常工作

在我显式调用的控制器的另一个函数下面,它也调用与索引函数相同的视图,但在输出中缺少背景图像

public function get_user() {
    $this->load->view('home/inc/header_view');
    $this->load->view('home/home_view');
    $this->load->view('home/inc/footer_view');
}

我不明白这个问题是什么,因为当我点击控制器时自动调用的index()函数与get_user()函数做的事情相同,但为什么get_user()中的输出不正确。请帮忙。感谢

为了避免每次转到不同页面时相关链接都发生更改,您需要自动加载uri帮助程序,并使用
base\u url()
将样式和脚本url包装如下:

background-image: url("<?php base_url('relative/path/to/image.img'); ?>");
背景图像:url(“”);

为了防止每次转到不同页面时相关链接都发生更改,您需要自动加载uri帮助程序,并使用
base\u url()
将样式和脚本url包装如下:

background-image: url("<?php base_url('relative/path/to/image.img'); ?>");
背景图像:url(“”);

为了防止每次转到不同页面时相关链接都发生更改,您需要自动加载uri帮助程序,并使用
base\u url()
将样式和脚本url包装如下:

background-image: url("<?php base_url('relative/path/to/image.img'); ?>");
背景图像:url(“”);

为了防止每次转到不同页面时相关链接都发生更改,您需要自动加载uri帮助程序,并使用
base\u url()
将样式和脚本url包装如下:

background-image: url("<?php base_url('relative/path/to/image.img'); ?>");
背景图像:url(“”);

在应用程序\config\config.php文件中设置baseurl,如下所示

 $config['base_url']    = 'http:/example.com/';//make sure it is your main path
background-image: url("<?php echo base_url();?>public/img/back1.jpg");
现在像这样改变身体样式

 $config['base_url']    = 'http:/example.com/';//make sure it is your main path
background-image: url("<?php echo base_url();?>public/img/back1.jpg");
背景图片:url(“public/img/back1.jpg”);
确保您有像
public/img
这样的文件夹,并且图像位于back1.jpg后面
希望它能帮助您在application\config\config.php文件中设置baseurl,如下所示

 $config['base_url']    = 'http:/example.com/';//make sure it is your main path
background-image: url("<?php echo base_url();?>public/img/back1.jpg");
现在像这样改变身体样式

 $config['base_url']    = 'http:/example.com/';//make sure it is your main path
background-image: url("<?php echo base_url();?>public/img/back1.jpg");
背景图片:url(“public/img/back1.jpg”);
确保您有像
public/img
这样的文件夹,并且图像位于back1.jpg后面
希望它能帮助您在application\config\config.php文件中设置baseurl,如下所示

 $config['base_url']    = 'http:/example.com/';//make sure it is your main path
background-image: url("<?php echo base_url();?>public/img/back1.jpg");
现在像这样改变身体样式

 $config['base_url']    = 'http:/example.com/';//make sure it is your main path
background-image: url("<?php echo base_url();?>public/img/back1.jpg");
背景图片:url(“public/img/back1.jpg”);
确保您有像
public/img
这样的文件夹,并且图像位于back1.jpg后面
希望它能帮助您在application\config\config.php文件中设置baseurl,如下所示

 $config['base_url']    = 'http:/example.com/';//make sure it is your main path
background-image: url("<?php echo base_url();?>public/img/back1.jpg");
现在像这样改变身体样式

 $config['base_url']    = 'http:/example.com/';//make sure it is your main path
background-image: url("<?php echo base_url();?>public/img/back1.jpg");
背景图片:url(“public/img/back1.jpg”);
确保您有像
public/img
这样的文件夹,并且图像位于back1.jpg后面
希望它能帮助你

使用基本url()函数

使用基本url()函数

使用基本url()函数

使用基本url()函数

背景图像:url(“”)。这就是我所做的,现在它不会在任何地方显示图像。你不需要包含“相对”,只需要从网站根目录到图像的路径<代码>基本url()提供
http://example.com/
括号中的内容在后面,所以说
base_url('public/img/back1.jpg')应该给你
http://example.com/public/img/back1.jpg
将其放回
背景图像:url(“public/img/back1.jpg”)
,然后查看两个页面上的源代码,查看两个页面的输出,查看有哪些更改。。。加载
index()
时,URL为
example.com/index.php/controller
,但
get_user()
上的URL为
example.com/index.php/controller/get_user
,这将破坏样式中的相对URL。。。您希望看到哪个正在工作,然后每次都使该URL相同。基本上,当您在
example.com/controller
上时,您指向
example.com/controller/public/img/back1.jpg
上的图像,但当您在
example.com/controller/get\u user
上时,您指向的图像位于
example.com/controller/get\u user/public/img/back1.jpg
,这与此不同。。。也许可以尝试
site\uURL('public/img/back1.jpg')
?背景图像:url(“”)这就是我所做的,现在它没有在任何地方显示图像。您不需要包含“relative”,只需要从站点根目录到图像的路径<代码>基本url()
提供
http://example.com/
括号中的内容在后面,所以说
base_url('public/img/back1.jpg')应该给你
http://example.com/public/img/back1.jpg
将其放回
背景图像:url(“public/img/back1.jpg”)
,然后查看两个页面上的源代码,查看两个页面的输出,查看有哪些更改。。。加载
index()
时,URL为
example.com/index.php/controller
,但
get_user()
上的URL为
example.com/index.php/controller/get_user
,这将破坏样式中的相对URL。。。您希望看到哪个正在工作,然后每次都使该URL相同。基本上,当您在
example.com/controller
上时,您指向
example.com/controller/public/img/back1.jpg
上的图像,但当您在
example.com/controller/get\u user
上时,您指向的图像位于
example.com/controller/get\u user/public/img/back1.jpg
,这与此不同。。。也许可以尝试
site\uURL('public/img/back1.jpg')
?背景图像:url(“”)这就是我所做的,现在它没有在任何地方显示图像。您不需要包含“relative”,只需要从站点根目录到图像的路径<代码>基本url()
provid