CodeIgniter Forums

Full Version: how to load the css
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]darshanchalla[/eluser]
Hi,
My page is not able to load the css when i am trying to load the page with default controller like this way http://localhost/mysite/ like this way css is not loaded......
when i am trying to load the page like this way http://localhost/mysite/index.php/site/index
css is loaded perfectly.....and i have put all my css folder and image folder like in this
path C:\wamp\www\tt\assets\css and all other application path is in the root path of the
tt like c:\wamp\www\tt\application....plz give me solution as

El Forum

[eluser]Metamorphosis[/eluser]
Hi.

try this in your header.php

Code:
<link href="<?php echo base_url();?>assets/css/name_of_css_file.css" rel="stylesheet" type="text/css" />

El Forum

[eluser]PhilTem[/eluser]
Or try it more fail-safe

Code:
<link href="<?php echo base_url('assets/css/name_of_css_file.css');?>" rel="stylesheet" type="text/css" />

Many people seem to forget that base_url() and site_url() take an argument that will be taken care of leading slashes and stuff so you don't run into troubles with that Wink

El Forum

[eluser]Otemu[/eluser]
[quote author="PhilTem" date="1359027820"]Or try it more fail-safe

Code:
<link href="<?php echo base_url('assets/css/name_of_css_file.css');?>" rel="stylesheet" type="text/css" />

Many people seem to forget that base_url() and site_url() take an argument that will be taken care of leading slashes and stuff so you don't run into troubles with that Wink[/quote]

Fantastic I didn't even know that :-)

El Forum

[eluser]darshanchalla[/eluser]
[quote author="PhilTem" date="1359027820"]Or try it more fail-safe

Code:
<link href="<?php echo base_url('assets/css/name_of_css_file.css');?>" rel="stylesheet" type="text/css" />

Many people seem to forget that base_url() and site_url() take an argument that will be taken care of leading slashes and stuff so you don't run into troubles with that Wink[/quote]





thank you very much to all of u Big Grin