Codeigniter: how to access css files from different views?


Tags: javascript,php,html,css,codeigniter

Problem :

My problem is that i cant seem to load my .css and .js files on my other views. The only single view that can access .css and .js files is my default_controller's index() function. The destination folder doesn't have any problem though because it can be accessed by the index function.

I want my .css and .js files be accessible to all my views.



Solution :

Add the following link to your header file

 <script src="<?php echo base_url() ?>js/hello.js" type="text/javascript" charset="utf-8"></script>

 <link rel="stylesheet" href="<?php echo base_url() ?>css/hello.css" type="text/css" charset="utf-8" />

For css

 make the folder in codeigniter folder like following
       codeigniter->css->hello.css

For js

 make the folder in codeigniter folder like following
       codeigniter->js->hello.js

    CSS Howto..

    how to add a different text box in input text type

    How do I bind data to a CSS property without using the style attribute of the element in Dart web-ui?

    How to replace @media (max-width) using Stylish or Greasemonkey?

    how to arrange div without disturbing the page design

    How can I change my div box to a link?

    How To Turn JS Objects To HTML And Style With CSS

    How to add another two full width sections below (CSS)

    css - why my text box is not showing up?

    How do you deal with the designing issues of a website?

    How to make a CSS file valid?

    Django. how to apply css style on boolean form field?

    CSS how to style the “content”/“background” attribute of a custom checkbox tick sign?

    How to get width of
  • stretched to available space in parent
      in IE7?
  • How to style form elements unobtrusively with JavaScript and CSS?

    How to echo individual css classes for li's?

    How do I add an attribute to a specific CSS class?

    How to get width of an image after setting the height

    How can i draw a box using css like the answer box in stackoverflow?

    How to put banner in css?

    How do I set background-image height using jQuery?

    How can I have floated list items display their bullet in IE7?

    How to make outer columns same height with nested bootstrap grids

    How to make Bootstrap navbar brand image larger

    100% width = viewport width. How to make it as wide as is page body instead?

    How to access smarty variable in css URL attribute?

    How do I make footer take 100% of the width of the webpage?

    jQuery Show/Hide - CSS display values are affecting my layout

    With CSS, how would I align this banner and navigation menu to XHTML 1.0 Strict specifications?

    How to do not apply CSS on a specific TAG

    How to resize & move css divisions at same time?