css没有链接到codeigniter中的html文件

时间:2022-11-22 19:12:10

I am new to CI , to test how it works i started by making css file an then a html file, but the problem is that i cannot link my css file to the html one.
This is my html:

我是CI的新手,测试它是如何工作的我开始制作css文件然后是一个html文件,但问题是我无法将我的css文件链接到html文件。这是我的HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="code/application/style/style.css">
<title>Insert title here</title>
</head>
<body>
 Hi
</body>
</html>

This is my css:

这是我的css:

body
{
    background-color: black ;
}

2 个解决方案

#1


1  

Images, css files etc need to reside outside the application folder, preferably in an "assets" folder that is located on the same level. You can then link to them in your views like so:

图像,css文件等需要驻留在应用程序文件夹之外,最好位于同一级别的“assets”文件夹中。然后,您可以在视图中链接到它们,如下所示:

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

Your folder structure would be:

您的文件夹结构将是:

ci-project
-index.php
-application
-assets
--css // --> style.css
--img // --> logo.png

#2


0  

Maybe ?:

<link rel="stylesheet" href="../code/application/style/style.css">

#1


1  

Images, css files etc need to reside outside the application folder, preferably in an "assets" folder that is located on the same level. You can then link to them in your views like so:

图像,css文件等需要驻留在应用程序文件夹之外,最好位于同一级别的“assets”文件夹中。然后,您可以在视图中链接到它们,如下所示:

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

Your folder structure would be:

您的文件夹结构将是:

ci-project
-index.php
-application
-assets
--css // --> style.css
--img // --> logo.png

#2


0  

Maybe ?:

<link rel="stylesheet" href="../code/application/style/style.css">