CSS doesn't work when I add slash (/) at the e

2019-08-02 23:23发布

问题:

I'm new to code igniter and I wonder why my css doesn't work when I add slash ( / ) at the end of the url ..

Can someone help me why it doesn't work ? And help me make it work ?

回答1:

Try this add code to your html head:

<link rel="stylesheet" href="<?php echo site_url('css/style.css');?>" type="text/css"/>

or

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


回答2:

CodeIgniter has method: site_url() - which generates your home url with '/' (slash) at the end.

To access public assets of your application use this:

<link type="text/css" rel="stylesheet" href="<?php echo site_url(); ?>public/css/smoothness/jquery-ui-1.10.2.custom.min.css">

<script type="text/javascript" src="<?php echo site_url(); ?>public/js/custom.modernizr.js"></script>

Note: href="<?php echo site_url(); ?>public/css/smoothness/jquery-ui-1.10.2.custom.min.css"