Welcome Guest, Not a member yet? Register   Sign In
css is not loading
#11

[eluser]mehwish[/eluser]
i have seen everything you are saying but the strange thing is taht when i first call my function it loads view correctly but when i navigate from that view to another it is creating problem. If anything was wrong with config etc. then on my first call to function it should not load css correctly
#12

[eluser]jblack199[/eluser]
no, because when you just load style.css without the use of base_url, its trying to load via whatever url the browser is at... ie:

http://localhost/myapp would work fine.. but http://localhost/myapp/2 wouldnt because the css file would be one directory down... but if you set your base_url to http://localhost/myapp/, and in your css link you added that in, it would work fine...

but to really know, you've got to see what your base_url is actually set to, if its set correctly and what the output it at the browser via view source to ensure that it truely is being read correctly.. if all is good, you'd have a 'direct link' to the css file meaning no matter what the url is, you'd have no issues with it loading.
#13

[eluser]Aken[/eluser]
Loading CSS, Javascript and other files in HTML like that is done on a relative basis, meaning it will start at the current URL / directory and go from there.

Loading CSS in this manner:
Code:
<link href="style.css"  charset="utf-8" rel="stylesheet" type="text/css" media="screen" />
... will look for the CSS file in various locations based on the URL. It is NOT consistent and wrong.
URL: http://www.example.com
Will look for CSS: http://www.example.com/style.css

URL: http://www.example.com/blog
Will look for CSS: http://www.example.com/blog/style.css

Using the base_url() function to output your base URL should work IF your style.css file is located in the root. This is a simple matter of making sure the URL in the <link> tag matches the URL of your CSS file if you were to view it through your browser.

If your CSS file is located in a directory called css, you'd access it here: http://www.example.com/css/style.css
Which would make your link URL:
Code:
<?php echo base_url(); ?>css/style.css




Theme © iAndrew 2016 - Forum software by © MyBB