我不明白为什么我的 css 不会链接到 html 文件。我已经尝试过代码段中显示的在线示例,但是这两个选项都不起作用。当我在浏览器中加载 localhost 文件夹时,html 页面肯定显示为文本“root-container”。任何帮助都会很棒!
尝试在链接前添加“应用程序”似乎也无济于事。例如。 '应用程序/ Assets /样式/navigation.css'。
此外,helper 和 url 已添加到自动加载配置文件中。
基本网址
$config['base_url'] = 'http://localhost/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;
}
添加请求的图片
结果文本应该是红色的,并且有划线穿过它。
okey,您将 Assets 文件移动到主目录并将 application/assets/style/navigation.css 编辑为 assets/style/navigation.css
我是一名优秀的程序员,十分优秀!