简体   繁体   English

如何在不同的文件夹中链接 CSS 和 HTML?

[英]How can I link CSS and HTML in different folders?

I have a stylesheet named style.css which is located inside a folder named css我有一个名为style.css的样式表,它位于名为 css 的文件夹内

And a HTML file named template.html in a folder named html还有一个名为template.html的 HTML 文件位于名为 html 的文件夹中

Both the folders are inside a folder named WebSite ( I guess that's the root folder. I'm new to html )这两个文件夹都在一个名为 WebSite 的文件夹中(我猜这是根文件夹。我是 html 的新手)

I want to link style.css to template.html using relative path.我想使用相对路径将 style.css 链接到 template.html。

My folder structure:我的文件夹结构:

WebSite
      |
      |--css
           |
           |--style.css
           |
      |--html
            |
            |--template.html
            |
      |--index.html

I tried using <link rel="stylesheet" href="../css/style.css" type="text/css" media="all" /> It didn't work我尝试使用<link rel="stylesheet" href="../css/style.css" type="text/css" media="all" />它没有用

For more clarity I tried using view-source: before the url and clicked on the link but it showed为了更清楚,我尝试使用查看源:在 url 之前并单击链接,但它显示

storage/emulated/0/WebSite/html/css/style.css (No such file or directory)

I am using Acode free app on Android mobile.我在 Android 手机上使用 Acode 免费应用程序。

I have misread what you were actually asking for my fault.我误读了你实际上是在问我的错。 First I would test out linking the css sheet with a test html document to see if its something to do with the app.首先,我将测试将 css 表与测试 html 文档链接,看看它是否与应用程序有关。 I dont know how "view source" works in this case but the view source is saying that your css folder, thus your css sheet is inside your html folder and according to your diagram explaining your folders, that is not true.我不知道在这种情况下“查看源代码”是如何工作的,但查看源代码是说您的 css 文件夹,因此您的 css 工作表在您的 html 文件夹内,并且根据您的图表解释了您的文件夹,而不是真正的文件夹。 In that case then your style sheet link would be <link rel="stylesheet" href="css/style.css" type="text/css" media="all"> An actual screenshot of your folder system, though not necessary, would be nice.在这种情况下,您的样式表链接将是<link rel="stylesheet" href="css/style.css" type="text/css" media="all">您的文件夹系统的实际屏幕截图,但不是必需的, 会好的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM