简体   繁体   中英

How do I get an image patch in CodeIgniter

I put the background image, but do not know relative address. I create a folder 'image' in 'application/assets/' and put same image here, but in css file not recognize the address.

body {
    background-image:url('assets/image/images2.jpg');
}

Same problem when I want to attach css file:

<link rel="stylesheet" type="text/css" href="public/css/ipics.css">

@globula_alba

Your best bet is to move your assets directory to the same level as applications & system, then reference all your images with base_url(), a Codeigniter function that matches your config.php base_url path.

So you will have:

base_url(). 'assets/images/myimage.gif';

or:

base_url('assets/images/myimage.gif');  

(They both work the same way)

You can do the same thing for your css & javascript files

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM