Php 如何在css Codeigniter中的背景url中包含基本url
大家好,我需要帮助,我正在尝试在css文件中包含背景url中的base_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
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>