CodeIgniter Forums
How to create a default css file for CI? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to create a default css file for CI? (/showthread.php?tid=21615)

Pages: 1 2 3


How to create a default css file for CI? - El Forum - 08-15-2009

[eluser]Shaheer[/eluser]
Hello, this is my first day at CI. i was creating a sample page and i succeed. But when i tried to add a css file it failed. I put the same css file in Views folder and System and main htdocs but it just didn't got attached. Can any one help?

Sorry for my English


How to create a default css file for CI? - El Forum - 08-15-2009

[eluser]tomcode[/eluser]
Welcome to CI Wink.

Using CI You should always use absolute URL's for assets( CSS, images, links), since depending on Your controller the page URL changes.

There are several possibilities, read the user guide.


In Your case use base_url() from either the url helper or the config class.


How to create a default css file for CI? - El Forum - 08-15-2009

[eluser]Shaheer[/eluser]
thanks for reply.

can you post the link to that page of user guide. i haven't covered CI completely yet i am using a book. so i didn't yet understand about that base_url thing. Please help.


How to create a default css file for CI? - El Forum - 08-15-2009

[eluser]tomcode[/eluser]
http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html

http://ellislab.com/codeigniter/user-guide/libraries/config.html, fetching config items


How to create a default css file for CI? - El Forum - 08-15-2009

[eluser]Slowcheetah[/eluser]
i use

Code:
<link href= "<?php echo base_url(); ?>assets/css/master.css" rel="stylesheet" type="text/css" />

And place my css:
codigniter_installation/assets/css/master.css


How to create a default css file for CI? - El Forum - 08-15-2009

[eluser]tomcode[/eluser]
Where do You have You index.php ?

webroot/index.php
webroot/codigniter_installation/index.php

The base_url always starts where Your index.php is.


How to create a default css file for CI? - El Forum - 08-16-2009

[eluser]Shaheer[/eluser]
it still doesn't work i have placed the style.css file in the same folder as index.php but no changes Sad
below is the view file

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;link rel="stylesheet" href="&lt;?php echo base_url(); ?&gt;style.css" /&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Web Test Site&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<h1>&lt;?php echo $mytitle; ?&gt;</h1>
<p class="test"> &lt;?php echo $mytext; ?&gt; </p>
&lt;?php echo $base ?&gt;
&lt;/body&gt;
&lt;/html&gt;

$base and other vars are passed by control.


How to create a default css file for CI? - El Forum - 08-16-2009

[eluser]Slowcheetah[/eluser]
What output has the folowing code?

Code:
&lt;?php echo base_url(); ?&gt;



How to create a default css file for CI? - El Forum - 08-16-2009

[eluser]tomcode[/eluser]
Check the resulting HTML code ...


How to create a default css file for CI? - El Forum - 08-16-2009

[eluser]Shaheer[/eluser]
first it was

http://www.example.com/ then i modified it to http://localhost.

is the problem with that?