在codeigniter的查看页面中包含CSS js [英] include css js in view page of codeigniter
问题描述
大家好,我在codeigniter中遇到如何包含CSS和jquery的问题。
hey everyone i'm facing a problem in codeigniter how to include css and jquery.
+application
+views
-welcome_message.php
+assets
+css
-template.css
+js
+system
+user_guide.
<link href='<?php echo base_url(); ?>application/assets/css/template.css' rel="stylesheet" type="text/css" />
萤火虫显示路径,例如:-
firebug show path like:-
<link type="text/css" rel="stylesheet" href="http://localhost/CodeIgniter_2.1.3/application/assets/css/template.css">
我不明白为什么CSS无法正常工作。
i don't understand why it's css is not working.
我在萤火虫上发现了这个东西:-
i find this thing on firebug:-
<link type="text/css" rel="stylesheet" href="http://localhost/CodeIgniter_2.1.3/assets/css/template.css">
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /CodeIgniter_2.1.3/assets/css/template.css was not found on this server.</p>
</body></html>
</link>
推荐答案
最佳做法是创建资产
目录外部 APPLICATION
目录不 内部 。
Best practice is to create an assets
Directory outside the APPLICATION
Directory not inside.
所以您的目录结构将是
+APPLICATION
+ASSETS
+SYSTEM
由您决定如何分配资源在资产目录中
its up to you how you divide the resources inside the ASSETS DIrectory
现在您可以使用 base_url()/ assets / your-directories / yourfiles.ext
来访问您想要的任何内容。或创建自己的助手
now you can use base_url()/assets/your-directories/yourfiles.ext
to access whatever you wanted. Or create your own helper
即
style_url();
script_url();
image_url();
这篇关于在codeigniter的查看页面中包含CSS js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!