doujinyi1267 2017-06-15 05:03
浏览 72
已采纳

我的CodeIgniter PHP中没有加载CSS文件

I am new in Codeigniter. I tried to load my css file but i failed. I search it google apply all solution but its not working.

I also made changes in mu autoload file

$autoload['helper'] = array('url', 'form');

Here is my Controller code with name Login.php

<?php
    class Login extends CI_Controller{
        function index(){
            $this->load->helper('url'); 
            $this->load->helper('html');
            $data['main_content'] = 'login_form';
            $this->load->view('include/template', $data);
        }
    }
?>

And Here is My View Code Name with login_form.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel = "stylesheet" type = "text/css" href = "<?php echo base_url();?>css/style.css">
<title>Untitled Document</title>
</head>

<body>
    <div id="login_form">
        <h1>Login Page..!!</h1>
        <?php
        echo form_open('login/validate_credentials');
        echo form_input('username', 'Username');
        echo form_password('password', 'Password');
        echo form_submit ('submit', 'Login');
        ?>

    </div>
</body>
</html>

Here is my Folder Structure

Config
controller
css
helper
models
views
  • 写回答

5条回答 默认 最新

  • duanqiang6501 2017-06-15 05:18
    关注

    Open your browser console by right clicking on your web page and select inspect.

    Go to your network requests / console and check what URL you get for your linked files (CSS).

    If you find out that the path you have given in your application if different then you need to change your code accordingly to get the appropriate path.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵