Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am new to codeigniter, and I am using v.2.12. I am getting an error when I try to load the css from the external file.

I create the css folder inside the application folder. And I create the css file in the name of all.css.

In the view file I use the following code to link the css file.

<link rel="stylesheet" type="text/css" href="<? echo base_url();?>css/all.css">

But the css file is not loading. I'm getting 404 error. Here is my configuration settings:

$config['base_url'] = 'http://webscarlets.com/ci/index.php';
$config['index_page'] = 'index.php';

Website Link: http://webscarlets.com/ci/index.php/welcome.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
333 views
Welcome To Ask or Share your Answers For Others

1 Answer

This is how you include CSS files in CodeIgniter:

<?php echo link_tag('css/mystyles.css'); ?>

That snippet will output this HTML:

<link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" />

The function link_tag is in the HTML helper, which must first be loaded.

(Note that you probably shouldn't put your CSS files in /application/css. It's just easier to put them in /css or maybe /assets/css.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...