• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CSS file is not loading

#1
[eluser]thepcfacer[/eluser]
Hello, I am trying to implement a template I found into CodeIgniter. However, the CSS file will not load. The view appears to load, but without the CSS file. Here is the line for loading it, can anyone help? The CSS file is in the View folder.

<link rel="stylesheet" type="text/css" href="action.css" media="screen,projection" />

#2
[eluser]imn.codeartist[/eluser]
its a path issue

instead of declaring
Code:
<link rel=“stylesheet” type=“text/css” href=“action.css” media=“screen,projection” />

copy your css where the index.php and system folder is

for example

css\action.css
system
index.php


and declare your css as follow

Code:
<link rel=“stylesheet” type=“text/css” href=“<?=base_url()?>css/action.css” media=“screen,projection” />

#3
[eluser]stef25[/eluser]
The path to your file is probably wrong. Here is the syntax I use to include css files, it works no matter where the files are located

Code:
<link rel="stylesheet" href="<?=base_url()?>_css/thickbox.css" type="text/css" />

Make sure that base_url is set correctly in your config.php. My value is

Code:
$config['base_url']    = "http://localhost:8888/site_name/";

#4
[eluser]umefarooq[/eluser]
better and easy way to use link tag with CI html helper link_tag() helper function

Code:
echo link_tag('css/mystyles.css');

check user guide

http://ellislab.com/codeigniter/user-gui...l#link_tag

#5
[eluser]thepcfacer[/eluser]
Thanks for the help so far but I am still getting this error message: Fatal error: Call to undefined function base_url() in C:\wamp\www\system\application\views\action_view.php on line 8

Line 8:
<link rel="stylesheet" type="text/css" href="<?=base_url()?> css/action.css" media="screen,projection" /> ?>
I also tried using the long php tags, but it still did not work.
<link rel="stylesheet" type="text/css" href=" <?php echo base_url()?> css/action.css" media="screen,projection" /> ?>

Base URL: $config['base_url'] = "http://localhost/";

action.css is currently in the following folders:
system/application/controllers
system/application/controllers/css
system/application/views
system/application/views/css

Any other suggestions?

#6
[eluser]stef25[/eluser]
Check in the Firebug Net tab or in your view source what the generated path is for the css file and report back Smile

Also, Your base path in the config file should include the folder name of where your site is located

And why is your css file in 4 different directories?

#7
[eluser]thepcfacer[/eluser]
Thanks for your help stef. I am not longer getting the error after adding in: <?php $this->load->helper('url'); ?>

However, the CSS is still not loading. The base URL is still
http://localhost/ - does this need to be updated?

<?php $this->load->helper('url'); ?>
<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>css/action.css" media="screen,projection" />

#8
[eluser]InsiteFX[/eluser]
Code:
$config['base_url'] = 'http://localhost/directory your ci app is in/'

Enjoy
InsiteFX

#9
[eluser]thepcfacer[/eluser]
$config['base_url'] = "http://localhost/";

CSS file is located at "system/application/css"

The CSS file loads at "http://localhost/" with this line in the view file:
<link rel="stylesheet" type="text/css" href="system/application/css/action.css" media="screen,projection" />

However, the CSS file DOES NOT load at this page: http://localhost/index.php/action

The application file (action.php) is located at application/controllers and the view is in application/views.

Any other suggestions?

#10
[eluser]umefarooq[/eluser]
for that you can use your css like this also

Code:
echo link_tag(APPPATH.'css/mystyles.css');

APPPATH is defined path till you application folder.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.