Welcome Guest, Not a member yet? Register   Sign In
How to Integrate Bootstrap or Tailwind CSS with CodeIgniter
#1
Wink 

Have you ever tried integrating Bootstrap or Tailwind CSS into your CodeIgniter project? What’s the best way to include these frameworks—using a CDN or downloading and linking them locally? Also, where do you usually place your CSS files in the CodeIgniter folder structure, and how do you manage responsive layouts within your views? Share your approach or any issues you faced while working with these CSS frameworks in CodeIgniter.
Reply
#2

(This post was last modified: 05-31-2025, 01:30 AM by captain-sensible. Edit Reason: usual suspects )

if you download and play with : https://sourceforge.net/projects/codeigniter4cms/  its got bootstrap , breakpoints in  css for mobile

head part of  main web template is :

Code:
<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $title ?>  </title>
<meta name="generator" content="Geany 1.38" />
<meta http-equiv="Content-Security-Policy" content=" default-src 'none';  form-action 'self'; frame-src 'self'  www.tiktok.com www.youtube.com;    style-src 'self' maxcdn.bootstrapcdn.com  cdn.jsdelivr.net      ; font-src 'self'  maxcdn.bootstrapcdn.com ;  img-src 'self'; script-src 'self'  https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js  https://www.xml-sitemaps.com/  www.tiktok.com    "        />
<link rel="stylesheet" type="text/css" href ="<?php echo base_url("css/myStyle.css"); ?>">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
</head>
<body>
<div class="d-flex flex-column mb-3 "  >


......................
footer next

....................

<script src="<?php echo base_url('js/popper.js');?>"></script>
<script src="<?php echo base_url('js/bootstrap.bundle.js');?>"></script>
<script src="<?php echo base_url('js/jquery-3.5.1.min.js');?>"></script>
<script src="<?php echo base_url('js/jquery-migrate-3.3.0.js');?>"></script>


overview layout:

Code:
[andrew@darkstar http]$ tree -L1 CI4-CMS
CI4-CMS
├── Gruntfile.js
├── LICENSE
├── LICENSE-CI4-CMS
├── README-codeigniter.md
├── README.md
├── app
├── clean.sh
├── composer.json
├── composer.lock
├── node_modules
├── package-lock.json
├── package.json
├── preload.php
├── preload_bk.php
├── public
├── scss
├── spark
├── vendor
└── writable

7 directories, 13 files
[andrew@darkstar http]$

[CODE]

public layout :



[code]
[andrew@darkstar CI4-CMS]$ tree -L2 public
public
├── blogImages
│   ├── 1739971214-andyAvatar.jpg
│   └── 1739971271-andyAvatar.jpg
├── captcha
│   ├── 0.png
│   ├── 1.png
│   ├── 2.png
│   ├── 3.png
│   ├── 4.png
│   ├── 5.png
│   ├── 6.png
│   ├── 7.png
│   ├── 8.png
│   └── 9.png
├── css
│   ├── bootstrap.css
│   ├── custom-bk.css
│   ├── custom-bk.css.map
│   ├── custom.css
│   ├── custom.css.map
│   ├── custom_bk.css
│   ├── custom_bk.css.map
│   ├── font-face-bk.css
│   ├── font-face.css
│   └── myStyle.css
├── favicon.ico
├── fonts
│   ├── Aaargh
│   ├── Antic
│   ├── Kingsthings
│   ├── LemonChicken
│   ├── Literata
│   ├── ShangriLaNF
│   ├── amadeus
│   ├── balgruf
│   ├── caroni
│   ├── dancing-script-ot
│   ├── kaushan-script
│   ├── magnolialight
│   ├── newtimesroman
│   ├── optima
│   ├── quikhand
│   ├── quintessential
│   └── times-new-roman
├── galleryImages
│   ├── andyAvatar.jpg
│   └── sewing-machinesmall.png
├── htaccess
├── images
│   ├── andy.jpg
│   ├── footer-image.png
│   ├── footer-image.xcf
│   ├── logo.png
│   ├── slug.gif
│   ├── tiktok.svg
│   ├── waiter.gif
│   └── you.png
├── index.php
├── index_bk.php
├── js
│   ├── bootstrap.bundle.js
│   ├── jquery-3.5.1.min.js
│   ├── jquery-migrate-3.3.0.js
│   ├── jquery-migrate.js
│   └── popper.js
├── robots.txt
└── sounds
    ├── Parisian.mp3
    └── spamsong.mp3
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply
#3

You should place all your assets in an assets directory under the public directory.

root
-- public
---- assets
------ bootstrap
------ css
------ js
------ img
------ images
------ icons
------ plugins
------ etc;

then follow @captain-sensible post for loading them.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

From the docs: Asset Dependencies Example.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB