(HTML) 在其他文件夹中链接 CSS 样式表但同一目录不起作用

2023-09-05前端开发问题
3

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

问题描述

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

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.

我把它放在我的 HTML 的标题标签中:

I put this in the header tag of my HTML:

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

但它不起作用.

该文件与我的 HTML 位于同一目录中的style"文件夹中.

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

当我将 CSS 文件和 HTML 文件放在同一个文件夹中并以相同的方式链接到它时,它可以工作href="stylesheet.css"

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:

推荐答案

该文件与我的 HTML 位于同一目录中的style"文件夹中.

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

不,不是.

图像显示 HTML 位于名为 LoggedIn 的文件夹中,CSS 位于名为 style 的文件夹中,但 stylenotLoggedIn 内.它是 LoggedIn 的同级目录,而不是它的子目录.

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.

所以在进入style之前,你需要上一层楼.

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

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

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

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

The End

相关推荐

layui 实现实时刷新一个外部的div
主页面上显示了一个合计,在删除和增加的时候需要更改这个总套数的值: //html代码div class="layui-inline layui-show-xs-block" style="margin-left: 10px" id="sumDiv"spanSOP合计:/spanspan${totalNum}/spanspan套/span/div 于是在我们删除这个条数据后,...
2024-11-14 前端开发问题
156

layui 单选框、复选框、下拉菜单不显示问题如何解决?
1. 如果是ajax嵌套了 页面, 请确保 只有最外层的页面引入了layui.css 和 layui.js ,内层页面 切记不要再次引入 2. 具体代码如下 layui.use(['form', 'upload'], function(){ var form = layui.form; form.render(); // 加入这一句});...
2024-11-09 前端开发问题
313

layui tree树组件怎么自定义添加图标
经常用到layui的朋友都知道,layui tree默认是不能自定义图标的,那么我们要自定义的话要怎么操作呢? 首先用编辑器软件(修改时候用编辑器记得编码),打开layui.js。搜索: i class="layui-icon layui-icon-file" 改为如下代码: i class="'+ (i.icon || "l...
2024-10-26 前端开发问题
493

layui要如何改变时间日历布局大小?
问题描述 我想改变layui时间日历布局大小,这个要怎么操作呢? 解决办法 可以用css样式对时间日历进行重新布局,具体代码如下: !DOCTYPE htmlhtmlheadmeta charset="UTF-8"title/titlelink rel="stylesheet" href="../../layui/css/layui.css" /style#test-...
2024-10-24 前端开发问题
271

jQuery怎么动态向页面添加代码?
append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href...
2024-10-18 前端开发问题
125

“数组中的每个孩子都应该有一个唯一的 key prop"仅在第一次呈现页面时
quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)...
2024-04-20 前端开发问题
5