【问题标题】:CodeIgniter CSS not workingCodeIgniter CSS 不工作
【发布时间】:2016-11-16 10:20:10
【问题描述】:

我正在使用 CodeIgniter,我正在尝试使用一些样式表。

在我的 autoload.php 中我有 $autoload['helper'] = array('html','url');

在我的查看页面上我有

<link rel="stylesheet" src="<?php echo base_url('assets/css/bootstrap.css')?>"/>
<link rel="stylesheet" src="<?php echo base_url('assets/css/bootstrap-theme.css')?>"/>
<script src="<?php echo base_url('assets/js/jquery-2.2.4.js')?>"></script>
<script src="<?php echo base_url('assets/js/bootstrap.js')?>"></script>

我正在尝试使用 Bootstrap 中的样式表来显示导航栏。

这是我的导航栏:

    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">
                    <img alt="Brand" src="...">
                </a>
            </div>
        </div>
    </nav>

问题是 CSS 似乎根本不起作用。

当我查看页面源代码时,我的&lt;head&gt;&lt;/head&gt; 标记中的样式表包含正确的链接,但页面本身没有任何变化。

【问题讨论】:

  • 检查控制台 |网络 tab.probably css 文件没有加载
  • @FastSnail 我应该寻找什么?似乎只有我的 javascripts 出现了,我在那里看不到任何 css 文件。但是当我进入我的页面源时,它们的链接是正确的。我该怎么办?
  • 浏览器控制台中的网络选项卡显示加载到您页面中的所有文件。因此,如果某些文件丢失,您可以看到 404 错误红色标记
  • 你也缺少类型type="text/css"

标签: php html css twitter-bootstrap codeigniter


【解决方案1】:

src 应该是href.read more

不要使用src 作为链接标签

<link rel="stylesheet" href="<?php echo base_url('assets/css/bootstrap.css')?>"/>

【讨论】:

  • 打败我!不错的地方。
  • 多么愚蠢的感觉。以前是src吗?我在这里找到了有问题的代码stackoverflow.com/questions/20697954/…
  • 这是&lt;script&gt;标签的src,这可能是你感到困惑的原因。
  • @GrumpyCrouton 这可能是个错误
猜你喜欢
  • 2016-05-09
  • 2012-11-26
  • 2014-06-26
  • 2014-04-15
  • 2012-12-02
  • 1970-01-01
  • 2018-06-16
  • 2016-03-01
  • 1970-01-01
相关资源
最近更新 更多