Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I include the CSS file in CodeIgniter?

I have make a assets folder in root directory where application folder exist. now I have assets sibling to application.

Now when I tried to open http://localhost/CodeIgniter/assets/css/bootstrap.min.css in web-page it's not working.

Do someone can help me how I can got it worked.

In a solution I found that writing this line in config file will work but it's not work either by doing this change.

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

Now please some guideline me how to load CSS file in CI.

solution :-

I have done something wrong in my codeigniter project. I download it again and try these thing again, without anything it's working.

thanks you all of guys. you save my time.

like image 521
user1814971 Avatar asked Dec 23 '12 05:12

user1814971


People also ask

Where do I put css file in CodeIgniter?

Adding JavaScript and CSS (Cascading Style Sheet) file in CodeIgniter is very simple. You have to create JS and CSS folder in root directory and copy all the . js files in JS folder and . css files in CSS folder as shown in the figure.

Can you include css in PHP?

You can add css styling to a page generated by php just the same as you would an ordinary html page. Typically you would link to a style sheet in the head section, or put the styling in <style> tags within the head. But you need to be more specific about what your needs are.

How do I link css to ci4?

By using link_tag() function, we can add stylesheet files i.e css files into templates. Suppose, style. css file is inside /public/css folder.

How do I add a css page in Visual Studio?

In Solution Explorer, right-click the name of the Web site, and then click Add New Item. In the list of templates, select Style Sheet. In the Name box, type Layout. css, and then click Add.


1 Answers

In constant.php:

define('URL','http://localhost/CodeIgniter/');
define('IMG',URL.'assets/img/');
define('CSS',URL.'assets/css/');
define('JS',URL.'assets/js/');

In config.php:

$config['base_url'] = URL;

In view:

<link rel="stylesheet" href="<?php echo(CSS.'bootstrap.min.css'); ?>">

Hope that helps somewhat.

like image 77
alditis Avatar answered Oct 04 '22 20:10

alditis