CodeIgniter - 加载CSS
我正在开发一个web解决方案的自定义API,我使用的是MVC设计模式。我有一个模块文件夹,以便我可以交换进出模块,也可以工作在不中断工作测试代码的部分。我现在唯一的问题是,我想加载CSS在任何地方,并让我的应用程序正确导入头文件中的CSS文件。我知道CodeIgniter这样做,但我不知道如何。
I am developing an custom API for a web solution and I am using the MVC design pattern. I have a modules folder so that I can swap in and out modules and also work on sections without disrupting working tested code. My only issue now is that I want to load CSS anywhere and have my application properly import the css file in the head tag. I know CodeIgniter does this but I'm not sure how.
使用PHP,如何加载在CSS文件中的任何地方,然后有正确的代码导入css像CodeIgniter的头像标签?
Using PHP, how do I load in a CSS file anywhere and then have the code properly import the css within the head tags like CodeIgniter does?
提前感谢。
因此,在这种情况下,我建议您创建一个标题视图,其中加载所有css和js文件
So in this case I recomend you to create one header view where you load all css and js files
示例:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<link rel="stylesheet" href="<?php echo base_url();?>css/moorainbow.css" type="text/css" media="screen"/>
</head>
<body>
并像这样调用:
$this->load->view('header');
$this->load->view('view1');
$this->load->view('view2');
这样你可以控制只加载一个文件的文件(css + js +等)。
This way you can control the files (css+js+etc) you load in just one file.
升级,
Pedro
@pcamacho
Regrads,
Pedro
@pcamacho