3

I am currently trying to load a css file into a CodeIgniter view in the follow manner:

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

A blank page is loaded. It seems that when I call the base_url function in the view the page doesn't load because the same thing happens when I call base_url() else where in the view but the page actually loads without css when I remove the calls to that function. Is there something that I need to require in order for the page to load?

4

3 回答 3

1

来自:http ://ellislab.com/codeigniter/user-guide/helpers/url_helper.html

使用以下代码加载此帮助程序:

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

可以使用以下功能:

...

您需要首先在调用的方法或类构造函数中加载帮助程序。

于 2013-07-10T07:07:10.623 回答
0

尝试导入注释。

<style> @import url('<echo base_url()?>/css/styles.css'); </style>
于 2013-07-10T07:16:22.737 回答
0

你可以这样做:

<link href="<?php echo base_url('assets/css/bootstrap.min.css') ?>" rel="stylesheet">
于 2013-07-10T10:01:18.030 回答