简体   繁体   中英

How do I load css files with a view in CodeIgniter?

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?

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

This helper is loaded using the following code:

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

The following functions are available:

...

You need to first load the helper either in the method called, or in the class constructor.

尝试导入注释。

<style> @import url('<echo base_url()?>/css/styles.css'); </style>

你可以这样做:

<link href="<?php echo base_url('assets/css/bootstrap.min.css') ?>" rel="stylesheet">

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