【问题标题】:CodeIgniter CSS will not link to htmlCodeIgniter CSS 不会链接到 html
【发布时间】:2018-08-15 21:58:51
【问题描述】:

我不明白为什么我的 css 不会链接到 html 文件。如代码段所示,我已经尝试了在线示例,但是这两个选项都不起作用。当我在浏览器中加载 localhost 文件夹时,html 页面肯定会显示为文本“root-container”。任何帮助都会很棒!

尝试在链接之前添加“应用程序”似乎也没有什么不同。例如。 'application/assets/style/navigation.css'。

此外,帮助程序和 url 已添加到自动加载配置文件中。

基本网址

$config['base_url'] = 'http://localhost/mysite/';

项目结构

省略根文件夹。假设根文件夹名称为“mysite”。所以 mysite -> 应用程序 -> ...

HTML

<!DOCTYPE html>
<html>

<head>
  <meta charset = "utf-8">

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

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

  <?php echo link_tag('assets/style/navigation.css'); ?>

</head>

<body>
  <div class = "root-container">
    root-container


  </div>
</body>

</html>

CSS

html {
 margin: 0 auto;
 padding: 0px;
}

body {
  margin: 0 auto;
  padding: 0px;
}

.root-container {
  width:100%;
  height:60px;
  border-bottom: 2px solid grey;
  background-color: black;
  color: red;

}

.root-container p {
  color:red;
  text-decoration: line-through;
}

添加请求的图片

结果 文本应该是红色的,并且有线条穿过它。

【问题讨论】:

    标签: html css codeigniter


    【解决方案1】:

    好的,你把 assets 文件移动到你的主目录,然后编辑 application/assets/style/navigation.css 到 assets/style/navigation.css

    【讨论】:

    • 请粘贴最后一个 css 链接?
    • application/assets/style/navigation.css
    • 打开网站并按 ctrl + u 并截图分享
    • 我已经添加了自动加载助手。不过感谢您的建议。
    • 您关于移动文件夹的建议奏效了,非常感谢!
    猜你喜欢
    • 2016-11-24
    • 2020-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-16
    • 2017-02-13
    相关资源
    最近更新 更多