CodeIgniter - 加载 CSS [英] CodeIgniter - Loading CSS
问题描述
我正在为 Web 解决方案开发自定义 API,并且我正在使用 MVC 设计模式.我有一个模块文件夹,这样我就可以换入和换出模块,还可以在不中断工作的测试代码的情况下处理部分.我现在唯一的问题是我想在任何地方加载 CSS 并让我的应用程序在 head 标记中正确导入 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 文件,然后让代码像 CodeIgniter 一样在 head 标签中正确导入 css?
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?
提前致谢.
推荐答案
您可以一次加载多个视图,或其他视图中的视图.
You can load several views at once, or views inside other views.
因此,在这种情况下,我建议您创建一个标题视图,您可以在其中加载所有 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+etc).
This way you can control the files (css+js+etc) you load in just one file.
重新毕业,
佩德罗
@pcamacho
Regrads,
Pedro
@pcamacho
这篇关于CodeIgniter - 加载 CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!