在codeigniter视图中放置css [英] Placing of css in codeigniter views
问题描述
我是新的codeigniter。我做了一个简单的控制器来加载三个视图:页眉,正文和页脚。我的标题包含到几个javascript和CSS的链接,它们有相对路径。我保持所有的css和js相对于文件在views文件夹。
问题是控制器加载一切正常,但图像,js和css没有加载。 / p>
这是我的视图的层次结构:
CSS(视图中的子目录)
JS视图中的子目录)
标题(标题视图文件)
正文(正文视图文件)
页脚(页脚视图文件)
ny想法?
假设这是你的目录:
Localhost
- 应用程式
- 控制器
- 视图
- 等等。
- 系统
- 资产
- JavaScript
- CSS
要包括任何javascript,路径将是:
localhost / Assets / Javascripts / your_script.js
/ p>
localhost / Assets / CSS / your_stylesheet.css
为了确保你的实现在任何地方都能正常工作,
< script src = <?= base_url('path / to / your / js / foo.js')> type =text / javascript>< / script>
将是最安全的方式
I am new to codeigniter. I made a simple controller to load the three views: header, body and footer. My header contains links to several javascripts and CSS which have a relative paths. I kept all the css and js relative to file in views folder.
The problem is that the controller loads everything properly but images, js and css are not getting loaded.
This is the hierarchy of my view:
CSS(sub directory in views) JS (sub directory in views)
header (header view file) body (body view file) footer (footer view file)
ny idea?
It is not a good idea to put everything in your view file, as those folders are supposed to clean things up, putting them in view makes them messy again.
Assume this is your directories:
Localhost
- Application
- Controllers
- Views
- Etc..
- System
- Assets
- Javascripts
- CSS
To include any of javascripts, the path would be:
localhost/Assets/Javascripts/your_script.js
and obviously CSS would be
localhost/Assets/CSS/your_stylesheet.css
In order to make sure your implementation work everywhere,
<script src="<?=base_url('path/to/your/js/foo.js')>" type="text/javascript"></script>
would be the safest way
这篇关于在codeigniter视图中放置css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!