html 未链接到 Visual Studio Code 中的 css 文件 [英] html not linking to css file in Visual Studio Code

查看:62
本文介绍了html 未链接到 Visual Studio Code 中的 css 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境

  • Windows 8.1 64 位
  • Visual Studio 代码 1.15.1

相关问题

  • 我想知道如何解决这个问题.

    编辑 17/9/3 19:03

    谢谢你们的回答,伙计们.以下方法无效.

    • href=../css/style.css"
    • href="~/css/style.css"
    • href="css/style.css"
    • 在标签中嵌入样式表(我想将 css 保存在一个单独的文件中)

    解决方案

    我不相信跳转到 css 类和 ids 是由 Vscode 原生支持的.试试 CSS Peek 扩展,它可以很好地满足您的需求.

    Environment

    • Windows 8.1 64bit
    • Visual Studio Code 1.15.1

    Related question

    Issue

    html doesn't link to css

    1. Classes and ids in css don't show up on Intellisense in html.
    2. When I put the cursor on a class or id in html and press F12 to jump to css, a window pops up and says "the definition wasn't found."

    However, when I open the html in a browser, the webpage is shown perfectly fine. So it seems like there is something wrong with my Visual Studio Code.

    html

    <!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;
    }
    

    files

    index.html
    css
    |
    +---style.css

    webpage

    I'd like to know how to get rid of this issue.

    Edit 17/9/3 19:03

    Thanks for the answers, guys. The following didn't work.

    • href="../css/style.css"
    • href="~/css/style.css"
    • href="css/style.css"
    • Embedding stylesheet in tag (And I want to keep css in a separate file)

    解决方案

    I don't believe jumping to css classes and ids is supported natively by Vscode. Try the CSS Peek extension, it does what you want nicely.

    这篇关于html 未链接到 Visual Studio Code 中的 css 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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