ChitranjanThakur
ChitranjanThakur

Reputation: 91

Style CSS does not With CodeIgniter - Baseurl

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?

Upvotes: 0

Views: 3972

Answers (4)

Shimanyi Valentino
Shimanyi Valentino

Reputation: 483

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>

Upvotes: 0

Wayne Tun
Wayne Tun

Reputation: 589

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.

Upvotes: 1

Muhammad Raheel
Muhammad Raheel

Reputation: 19882

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.

Upvotes: 1

Biswajit Maji
Biswajit Maji

Reputation: 889

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

Upvotes: 0

Related Questions