【问题标题】:Unable to load css in codeigniter platform无法在 codeigniter 平台中加载 css
【发布时间】:2018-05-30 09:02:56
【问题描述】:

我在尝试在 template/header.php 和 footer.php 中加载 css 时遇到问题,并且在执行此操作时遇到问题。

我的 codeignitor 应用程序的结构是

-application
-views

-- css (folder)
     --- style.css
-- template (folder)
     ---header.php

在 header.php 中,我使用以下行来加载 css

<style> @import url('<?=base_url()?>css/style.css'); </style>

在 Web 控制台中,我将其视为

GET http://localhost/groce/css/style.css [HTTP/1.1 404 Not Found 1ms]

groce 是我的应用程序的名称

【问题讨论】:

  • 把css文件夹放到你项目的根目录下
  • 将您的 index.php 和任何 css、js 和图像文件夹放入“公共”目录并使其成为您的 Web 根目录的好习惯

标签: php css codeigniter


【解决方案1】:

试试这个:

<link rel="stylesheet" href="<?=site_url('css/style.css');?>" type="text/css"/>

你需要这样的应用结构:

-application
-css
-system
index.php
.htaccess

还需要添加css文件夹来重写.htaccess中的条件

RewriteCond $1 !^(index\.php|css)

【讨论】:

    【解决方案2】:

    尝试正确的一个::

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

    结构::

    -application
    -css
    -system
    

    【讨论】:

      猜你喜欢
      • 2015-05-28
      • 1970-01-01
      • 1970-01-01
      • 2016-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-05
      • 1970-01-01
      相关资源
      最近更新 更多