【发布时间】:2020-12-25 20:55:29
【问题描述】:
我正在尝试链接到我的 HTML 索引文件中的 CSS 文件。这只是一行代码,显然无论我尝试什么都行不通。我正在使用 VSCode。
- 如果我从头开始键入链接,它也会自动完成(或者无论如何都会显示)。所以它知道它就在那里。
- 我还尝试将 CSS 文件移出文件夹并放在 HTML 文件旁边。但这也不起作用。
- 我尝试了 HTML 文件本身中的样式括号,并且其中的颜色有效。
所以我的测试方法是没有任何东西显示为蓝色。
我还将我的 Javascript 从 HTML 文件中删除到一个单独的文件中,该文件链接到该文件以提高该问题的可读性,并且 确实 工作
还有其他人有什么想法吗?
我还看到了针对同一问题的其他主题,但没有任何新的尝试。
<!DOCTYPE html>
<html>
<head>
<title>Calculator</title>
<meta charset="UTF-8">
<link rel=”stylesheet” type="text/css" href="styles/style.css">
</head>
<body>
<a id="stringCalculation"></a><br>
<a id="stringResult"></a>
<br>
<div id="container-numbers">
<button id="one" class="number">1</button>
<button id="two" class="number">2</button>
<button id="three" class="number">3</button>
<button id="four" class="number">4</button>
<button id="five" class="number">5</button>
<button id="six" class="number">6</button>
<button id="seven" class="number">7</button>
<button id="eight" class="number">8</button>
<button id="nine" class="number">9</button>
<button id="zero" class="number">0</button>
</div>
<div id="operators">
<button id="symbolPlus" class="operator">+</button>
<button id="symbolMinus" class="operator">-</button>
<button id="symbolTimes" class="operator">*</button>
<button id="symbolDivid" class="operator">/</button>
<button id="equals">=</button>
</div>
<div id="other">
<button id="clearButton">Clear</button><br>
<button id="backspace">Backsp</button>
<button id="decimal">.</button>
</div>
<script src="javascript/myscript.js"></script>
</body>
</html>
还有 CSS 文件:
#one {
background-color: blue;
}
.number {
background-color: blue;
}
这是我的文件夹:
里面:
【问题讨论】:
-
可以显示你的文件夹结构吗?这工作正常。
-
检查 DevTools 网络选项卡。文件是否已加载?检查 Inspector 选项卡,元素是否应用了被覆盖的 CSS?
-
我真的认为您链接到 HTML 的 CSS 文件的路径存在问题。也许你有一个可以检查的链接?
-
现在应该可见
-
这是一个错字
”stylesheet”- 将引号更改为标准引号。