CodeIgniter Forums
css are not loading - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forum-11.html)
+--- Thread: css are not loading (/thread-70625.html)

Pages: 1 2


css are not loading - davy_yg - 05-05-2018

Hello,

I wonder why the css files are not loading?


views/index.php

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


config.php

       $config['base_url'] = 'http://localhost/coolcicms/';


File location:

coolcicms/assets/css/style.css
coolcicms/assets/css/custom.css

I already autoload the url helpder.


RE: css are not loading - jreklund - 05-05-2018

Right click -> View source


RE: css are not loading - Paradinight - 05-05-2018

(05-05-2018, 06:40 AM)jreklund Wrote: Right click -> View source

F12 and the network tab Smile


RE: css are not loading - davy_yg - 05-05-2018

In the Network Tab

Request URL:
http://localhost/coolcicms/index.php/<? echo base_url('assets/css/style.css'); ?>
Request Method:
GET


RE: [SOLVED] css are not loading - davy_yg - 05-06-2018

I think I am going to post the solution that I discovered.

<?php echo base_url('assets/css/style.css'); ?>


RE: [SOLVED] css are not loading - BobM - 05-07-2018

(05-05-2018, 06:30 AM)davy_yg Wrote: Hello,

I wonder why the css files are not loading?


views/index.php

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


config.php

       $config['base_url'] = 'http://localhost/coolcicms/';


File location:

coolcicms/assets/css/style.css
coolcicms/assets/css/custom.css

I already autoload the url helpder.

Use this:
<link rel="stylesheet" href="<?= echo base_url('assets/css/style.css'); ?>">
<link rel="stylesheet" href="<?= echo base_url('assets/css/custom.css'); ?>">

"<?" does not mean "echo" or "print" but "<?=" does


RE: [SOLVED] css are not loading - jreklund - 05-07-2018

@BobM: Now you got double echo. <?= echo means <?php echo echo.

<? are shorthand for <?php if you have activated it. So it works on some systems.


RE: [SOLVED] css are not loading - davy_yg - 05-15-2018

"<? are shorthand for <?php if you have activated it. "

How to activated it?


RE: css are not loading - InsiteFX - 05-16-2018

It should be like this:

PHP Code:
<link rel="stylesheet" href="<?= base_url('assets/css/style.css'); ?>"

And this is why they say do not use SHORT OPEN TAGS...


RE: css are not loading - Amonza - 06-12-2018

Guys I'm having the same problem.

My code in my view file.
<link rel="stylesheet" href="<?= base_url('bootstrap/css/bootstrap.min.css'); ?>" type="text/css">

The bootstrap assets are in a folder called bootstrap at the same level as the application folder.

/path/to/web/root/
├── application/
└── views/
├── templates
├── header.php
├── footer.php
├── system/
├── bootstrap/

rendered output
<link rel="stylesheet" href="http://localhost/codeigniter/bootstrap/css/bootstrap.min.css" type="text/css">

I've tried different locations within the project, nesting it in the application folder and under views but with the same non result even thought the path always seems to correct in relation to the local folder structure. Trying to access the css files directly through the browser generates a 404?

If I link to external css files they load fine.

What esoteric thing could be going on here? I've spent a nearly a day on this and its driving me insane.

I've got myself ready for a massive face palm.

TIA