0

This question has been asked several times, but have not found the right answer which will work on my project.

my CSS file liking

<link rel="stylesheet" type="text/css" href="assets/css/style.css"/>

The css file is in:

-main_directory
  -Application
  -Assets
    -css
       -style.css
  -System

I also tried to link css using base_url href="<?php echo base_url('assets/css/style.css');?>" but it doesn't work for me.

So what is the problem? Can anyone help?

3
  • see stackoverflow.com/questions/6630770/… Commented Apr 20, 2013 at 9:42
  • have u loaded url helper? Commented Apr 20, 2013 at 10:50
  • make your practice to accept answer if you think some answer is useful to you. Commented Apr 20, 2013 at 19:10

4 Answers 4

1

Your structure should be like this

myproject
  application
  assets
    css
       style.css
 system

autoload url helper in config/autoload.php

$autoload['helper'] = array('url');

Now

<link href = '<?php echo base_url()?>/assets/css/style.css'>

This should work. Make sure your spellings are correct and see the casd sensitive issue if you are using linux.

Sign up to request clarification or add additional context in comments.

Comments

1

is your base_url() method config properly? Check here...

ci_app_folder/config/config.php

if yours is located in c:/xampp/htdocs/ci_app_name

$config['base_url'] = 'localhost/ci_app_name'; //or localhost:90/ci_app_name if you had changed port

Then you can use this

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

You can also set base_url() empty . If you haven't uploaded to web hosting/server.

Comments

0
Try this once -
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/style.css" />

Comments

0

You could place the custom css links like this :

    background-image:url(../../); moving back to the directory you want

using CI you need to use in-line css: eg.

    <div style = background-image: url(<?php echo base_url();?>)assets/images/>
    </div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.