Welcome Guest, Not a member yet? Register   Sign In
css not working on my site
#1

[eluser]dinisptc[/eluser]

this is my httpd.conf

<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/site
SetEnv APPLICATION_ENV "development"
<Directory /var/www/site>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


my autoload

$autoload['helper'] = array('html','url','form');


this a part the header of my html

<!DOCTYPE html>
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;Welcome to CodeIgniter&lt;/title&gt;

&lt;!--http://localhost/application/views/style.css--&gt;
&lt;link href="&lt;?php echo base_url()."application/views/style.css"?&gt;"rel="stylesheet" type="text/css" /&gt;
&lt;!--&lt;link href="&lt;?php echo base_url()."application/views/style.css"?&gt;"rel="stylesheet" type="text/css" /&gt;--&gt;
&lt;!--&lt;link rel="stylesheet" href="&lt;?=base_url();?&gt;application/views/style.css" type="text/css" /&gt;--&gt;

&lt;/head&gt;
&lt;body&gt;



&lt;?php echo "ola";?&gt;
&lt;?php echo base_url();?&gt;</br>
&lt;?php echo base_url()."application/views/style.css"?&gt;


<div id="wrapper">
....

this is my config

$config['base_url'] = 'localhost/';

the website location its at /var/www/site

the location of the css
/var/www/site
/var/www/site/application/views/styles.css


thanks

pedro


the css its not working



#2

[eluser]TWP Marketing[/eluser]
[EDIT] You don't need my php echo, so I removed it.

Move your css files to a separate 'css' folder at the root level

Code:
/css
/application
/system

Then your header css link would look like this:

Code:
&lt;link rel='stylesheet' type='text/css' media='all' href="css/styles.css" />


You can even go one level further and create a separate assets folder:

Code:
/assets
  |
  /css
  /js
  /images
/application
/system

Then your header css link would look like this:

Code:
&lt;link rel='stylesheet' type='text/css' media='all' href="assets/css/styles.css" />
#3

[eluser]dinisptc[/eluser]
thanks


its working now
#4

[eluser]Leon Stafford[/eluser]
I'd also recommend using a variable or constant for storing media paths, ie

define("CSS_PATH", "assets/css/");
define("JS_PATH", "assets/js/");
define("IMG_PATH", "assets/img/");

and so forth.

Then in your views, you can include as such:

&lt;link rel='stylesheet' type='text/css' media='all' href="&lt;?=CSS_PATH;?&gt;styles.css" /&gt;

This helps when you are not sure if you will be changing the folders later on, which would otherwise require some recursive find and replacing.

I use both methods, whichever you are comfortable using.




Theme © iAndrew 2016 - Forum software by © MyBB