CSS doesn't work when I add slash (/) at the end of my url

给你一囗甜甜゛ 提交于 2019-12-11 08:48:55

问题


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"



来源:https://stackoverflow.com/questions/18482518/css-doesnt-work-when-i-add-slash-at-the-end-of-my-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!