CodeIgniter - 加载CSS [英] CodeIgniter - Loading CSS

查看:83
本文介绍了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

这篇关于CodeIgniter - 加载CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆