(HTML)在其他文件夹中链接了CSS样式表,但同一个目录不起作用 [英] (HTML) linked CSS stylesheet in other folder but same directory doesn't work

查看:54
本文介绍了(HTML)在其他文件夹中链接了CSS样式表,但同一个目录不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个初学者,正尝试创建一个网站并将CSS样式表存储在HTML文件所在的不同文件夹中,但存储在相同目录中./p>

我将其放在HTML的标头标记中

 < link rel ="stylesheet" type ="text/css" media ="screen" href ="./style/stylesheet.css"/> 

但它不起作用.

该文件位于与我的HTML相同的目录中的样式"文件夹中.

当我将CSS文件和HTML文件放在同一文件夹中并以相同的方式链接到时,此方法有效href ="stylesheet.css"

我在寻找其他修复程序,检查了错别字,但似乎已经正确链接了吗?我还尝试了各种不同的方式来键入路径,但是没有任何效果.

这是文件夹的结构方式:

解决方案

该文件位于与我的HTML相同的目录中的样式"文件夹中.

不,不是.

该图像显示HTML位于名为 LoggedIn 的文件夹中,而CSS位于名为 style 的文件夹中,但 style 为< LoggedIn 中的em> not .它是 LoggedIn 的同级目录,而不是其子目录.

因此,在进入样式之前,您需要先上一层楼.

./(当前目录)替换为 ../(父目录).

I am a total beginner and am trying to create a website and store the CSS stylesheet in a different folder that the HTML files, but in the same directory.

I put this in the header tag of my HTML:

<link rel="stylesheet" type="text/css" media="screen" href="./style/stylesheet.css" />

but it doesn't work.

The file is in the folder "style" in the same directory as my HTML.

It works, when I have the CSS file and the HTML file in the same folder and link to it in the same way with href="stylesheet.css"

I have looked for other fixes, checked for typos, but it seems to be linked correctly already? I have also tried around different ways to type the path, but nothing works.

This is the way the folders are structured:

解决方案

The file is in the folder "style" in the same directory as my HTML.

No, it isn't.

The image shows that the HTML is in a folder named LoggedIn, and the CSS is in a folder called style but style is not inside LoggedIn. It is a sibling directory of LoggedIn not a subdirectory of it.

So you need to go up a level before you go down into style.

Replace ./ (the current directory) with ../ (the parent directory).

这篇关于(HTML)在其他文件夹中链接了CSS样式表,但同一个目录不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆