rawsid96 rawsid96 - 4 months ago 13
HTML Question

when i normally run html bootstrap enabled code, it shows proper output but when i load it using codeigniter view it shows different output

This is my directory:

miuse/application

miuse/application/views/templates/header.php

miuse/bootstrap/css

miuse/bootstrap/js

miuse/bootstrap/fonts

This is my controller code:

<?php
class page extends CI_controller{
public function view($page= 'home')
{
if(!file_exists(APPPATH.'views/pages/'.$page.'.php'))
{
show_404();
}
$data['title']='Moodlist home';
$this->load->view('templates/header', $data);
}
}
?>


This is my view code:

<!DOCTYPE html>
<html lang="en">
<head>
<title>
<?php echo $title; ?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="http://localhost/miuse/bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="header.css" type="text/css">

</head>
<body>
<header class="container">
<div class="row">
<h1 class="col-sm-4">List</h1>
<nav class="col-sm-8 text-right">
<p>Home</p>
<p>Category</p>
<p>About us</p>
</nav>
</div>
</header>
</body>
</html>


when i run my view normally in a browser it shows proper output but when i load it with codeigniter view then it shows different output which i dont want.

Answer

I guess your header.css file is not being loaded.

Put the header.css file in miuse/bootstrap/css directory.

And change your code from,

<link rel="stylesheet" href="header.css" type="text/css">

to

<link rel="stylesheet" href="http://localhost/miuse/bootstrap/header.css" type="text/css">