Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在css Codeigniter中的背景url中包含基本url_Php_Html_Css_Codeigniter - Fatal编程技术网

Php 如何在css Codeigniter中的背景url中包含基本url

Php 如何在css Codeigniter中的背景url中包含基本url,php,html,css,codeigniter,Php,Html,Css,Codeigniter,大家好,我需要帮助,我正在尝试在css文件中包含背景url中的base_url,但它不起作用,请在这方面我需要帮助 background: url('<?php echo base_url();?>assets/images/re_1.png') repeat; color: #413c35; -webkit-font-smoothing: antialiased; overflow-x: hidden; background:url('assets/images/re_1.p

大家好,我需要帮助,我正在尝试在css文件中包含背景url中的base_url,但它不起作用,请在这方面我需要帮助

  background: url('<?php echo base_url();?>assets/images/re_1.png') repeat;
color: #413c35;
-webkit-font-smoothing: antialiased;
overflow-x: hidden;
background:url('assets/images/re_1.png')重复;
颜色:#413c35;
-webkit字体平滑:抗锯齿;
溢出x:隐藏;
试试这个:

body {
 background:#356aa0 url(../img/background.png) repeat-x;
 color:#fff;
}
现在就叫它:

<link rel="stylesheet" type="text/css" href="<?=base_url()?>css/style.css"/>
试试这个

css

html


在您的视图中编写css

<style>
.blah{ 
   background: url('<?php echo base_url();?>assets/images/re_1.png') repeat;
  color: #413c35;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  }
</style>

布拉赫先生{
背景:url('assets/images/re_1.png')重复;
颜色:#413c35;
-webkit字体平滑:抗锯齿;
溢出x:隐藏;
}

您不能在css中运行php代码,不要尝试这样做,那么我可以做什么呢?您可以使用javascript+php,使用javascript可以应用样式,使用php可以将base_url()传递给java脚本,或者您可以提供由@Sumanta736定义的相对路径css文件放置在哪里?
 <link rel="stylesheet" href="<?php echo base_url('example.css');?>">
<style>
.blah{ 
   background: url('<?php echo base_url();?>assets/images/re_1.png') repeat;
  color: #413c35;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  }
</style>