1

i want to connect my external css into the page. the css placed on C:\wamp\www\QBCI\Style\syle.css and i am using autoload helper $autoload['helper'] = array("html","form","url");

so, i write the css connector like this <link href="<?php echo base_url(); ?>Style/style.css" type="text/css" rel="stylesheet" /> and now here is the view

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

<body>

    <div class ="header">
        http://localhost/QBCI/  //i was echoing base_url() 
    </div>

    <div class ="content">


    </div>



</body>

and finally, here is my base url at config.php $config['base_url'] = 'http://localhost/QBCI';

stucture

why is the style.css is not loaded ? what did i do wrong ?

solved, i made the css file "syle.css" instead of "style.css" sorry guys, thank you for your support

2
  • Can we have a link to a demo, or maybe the content of your htaccess if you have one? Or maybe the value returned by base_url()? Commented Sep 20, 2012 at 18:29
  • @nebulousgirl i did <?php echo base_url() ?> at the view's div, it prints like this http://localhost/QBCI/ Commented Sep 20, 2012 at 18:33

4 Answers 4

1

Try

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

Make sure your .htaccess works and your style/ directory is in the right place (in the same folder with index.php in most cases).

As you are using a subfolder (QBCI), make sure you have it in your .htaccess rewrite path.

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

10 Comments

why don't you prefer to use base_url() ?
base_url(); should be used in this case as site_url(); is for page urls. See codeigniter.com/user_guide/helpers/url_helper.html
I am really sorry, I have mistaken here, surely base_url() should be used. Editing my answer
@nebulousgirl sorry, still not work, i made this <link href="<?php echo base_url('style/style.css'); ?>" type="text/css" rel="stylesheet" />
@nencor what does firebug/developer tools show you? What error do you get? What do you see in view source?
|
0

Did you make sure to set $config['base_url'] = ''; in your config/config.php?

Additionally the documentation suggests that you pass the base_url function the path instead of concatenating it, it shouldn't make that big of difference but.. http://codeigniter.com/user_guide/helpers/url_helper.html

Comments

0

You need to add a trailing slash to your base_url value:

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

4 Comments

If you view source in your web browser, what value is the href value corresponding to your style sheet?
Ok, @nencor, if you click on that link in the source viewer of your web browser, does it display the CSS?
no it isn't, it display <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL /QBCI/style/style.css was not found on this server.</p> </body></html>
@nencor personally I'd make the path lower case (try changing the folder from 'Style' to 'style') and all of the references to it lower case too.
0

your file is under Style/syle.css not style.css you must rename the file because you are missing a t

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.