dongtun2572 2016-07-08 06:47
浏览 68
已采纳

在css中的路径在codeigniter中调用背景图像

i load my css like this

<link href="<?php echo base_url('assets/css/home/css/style.css');?>" rel="stylesheet" type="text/css" media="all"/>

Now I want to call a background image from my style CSS something like this:

background: url(../assets/img/home/images/cover.jpeg)no-repeat center;

But this doesn't work

Can someone tell me how I call the image file from CSS?

My file structure is assets/img/home/images/cover.jpeg

My css structure is assets/css/home/css/style.css

  • 写回答

2条回答 默认 最新

  • dpka7974 2016-07-08 06:58
    关注

    Please update your question and put your file structure. Assuming that your css file is inside the css folder and image file inside img folder within the assets directory.

    Call html helper inside your controller:

    $this->load->helper('html');

    How to call the stylesheet:

    <?php echo link_tag('assets/css/home/css/style.css'); ?>
    

    Try to change the url like this:

    background: url(../img/home/images/cover.jpeg)no-repeat center;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 slam rangenet++配置
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊