Link to the CodeIgniter stylesheet. AS?

I am using xampp for my php. And I download the code igniter and save it on my htdocs. I already made a database and a sample page. My only problem is how can I link my css. Where should I save my style.css? How can I name my style .css?

 <link rel = "stylesheet" href = "<? base_url ();?> stylesheet / style.css" type = "text / css" media = "screen" />

I have this, but still have a problem. Is there any step by step on how to link css?

Thanks.

+7
php codeigniter
source share
7 answers

Put your CSS wherever you want, and then draw this URL.

Try putting it in the "/css/test.css for example" / folder that is the root of your site, not your CI.

From CI, you can call it with

<?= link_tag(base_url().'css/test.css'); ?> 

This should generate the following code

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

If you're having trouble customizing your CSS, the easiest way to find out where your script is trying to call it is to look at the source output of your web pages. You will see exactly where CI thinks it is located.

+10
source share

You can put your stylesheet anywhere - it's just a matter of setting up your directory correctly. The code you posted will look in your main directory (folder with license, system, user_guide, etc. This will look for a folder called "stylesheet" and then for style.css.

Make sure you have a style sheet.

+2
source share

Using the Firefox FireBug plugin will help you with this. Look at the HTML source code that was displayed and find out where the browser is looking for this stylesheet and make sure it is there.

+2
source share

This is Syed Haroon from Mysore, Karnataka, India.

Suppose: Root folder name: ci_test CSS file name: mystyles.css "; Controller file name: Start.php view file name: test_view.php

Decision:

Suggestion for WAMP (hope this will be easy to fix in xampp):

Save it in root / system / application / css file

Create a new CSS directory in the application folder (only for proper file and folder management)

How to connect to CSS file?

in system / application / config / config.php Change "$ config ['base_url'] = http: // localhost / " to

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

Enter a new line

 $config['css'] = "system/application/css/mystyles.css"; 

Create a controller in "system / application / controller / start.php", insert the following code example:

 class Start extends Controller { var $base; var $css; function Start(){ parent::Controller(); $this->base = $this->config->item('base_url'); $this->css = $this->config->item('css'); } function hello(){ $data['css'] = $this->css; $data['base'] = $this->base; $data['mytitle'] = 'Welcome to this site'; $data['mytext'] = "Hello, now this is how CSS work!"; $this->load->view('test_view', $data); } } 

Contain the view file in "system / application / views / test_view.php" insert the following code sample:

 <html> <head> <title>Web test Site</title> <base href= <?php echo "$base"; ?> > <link rel="stylesheet" type="text/css" href="<?php echo "$base/$css";?>"> </head> <body> <h1><?php echo $mytitle; ?> </h1> <p class='test'> <?php echo $mytext; ?> </p> </body> </html> 

now enter this in the address bar of your browser " http: //localhost/ci_test/index.php/start/hello/ "

+1
source share

The easiest way to do this is to put the css file in the same directory with the index.php file and link to it using <link rel="stylesheet" type="text/css" href="style.css" /> , or if If you have more than one css file, you can create a subdirectory in which you can place them.

0
source share

I think the best way is to create a shared folder. Put css and js and the images folder in the shared folder.

Make the .htaccess file in the root folder. (where index.php)

Put this in your .htaccess file:

 RewriteEngine On RewriteCond $1 !^(index\.php|images|js|css) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] RewriteCond $1 ^(images|js|css) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./public/$1 [L,QSA] 

After that, you can link to the files as follows:

 <img src="/images/blablabla.jpg"> 

Or / css / blabla.css, etc ...

0
source share

My file my file path <link href="<?php echo base_url();?>assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/> & does not work.

Finally, I used

RewriteEngine on RewriteCond $1 !^(index\.php|images|assets|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]

in my .htaccess file and it works now. You can rename your file, not "assets", the name of my style.

0
source share

All Articles