环境
- Windows 8.1 64 位
- 视觉工作室代码 1.15.1
相关问题
问题
html 没有链接到 css
- css 中的类和 id 不会显示在 html 中的 Intellisense 上。
- 当我把光标放在html中的某个类或id上按F12跳转到css时,弹出一个窗口说“找不到定义”。
但是,当我在浏览器中打开 html 时,网页显示得非常好。所以我的 Visual Studio Code 似乎有问题。
网页格式
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="./css/style.css">
</head>
<body>
<div class="abc"></div>
<div id="xyz"></div>
</body>
</html>
CSS
.abc{
width: 100px;
height: 100px;
background: red;
}
#xyz{
width: 100px;
height: 100px;
background: blue;
}
文件
索引.html
CSS
|
+—样式.css
网页
我想知道如何摆脱这个问题。
编辑 17/9/3 19:03
谢谢你们的回答,伙计们。以下没有工作。
href="../css/style.css"
href="~/css/style.css"
href="css/style.css"
- 在标签中嵌入样式表(我想将 css 保存在一个单独的文件中)
原文由 dixhom 发布,翻译遵循 CC BY-SA 4.0 许可协议
我不相信 Vscode 本机支持跳转到 css 类和 id。尝试 CSS Peek 扩展,它可以很好地满足您的需求。