VS code CSS class selector not found with angular and bootstrap 5 beta

前端 未结 11 1880
陌清茗
陌清茗 2021-02-05 02:31

I\'m using bootstrap 5 with angular and I add style and script to angular.json but the problem in VS Code it does not recognize the bootstrap classes.

相关标签:
11条回答
  • 2021-02-05 03:29

    Install this extension https://marketplace.visualstudio.com/items?itemName=ecmel.vscode-html-css

    Then in your .vscode/settings.json:

    {
      "css.styleSheets": [
        "https://cdn.jsdelivr.net/npm/bootstrap@5.0.0beta1/dist/css/bootstrap.min.css"
      ]
    }
    

    Restart vscode. Worked for me.

    0 讨论(0)
  • 2021-02-05 03:29

    As said by others, uninstall the HTML CSS Support then reload VS code. You can use IntelliSense for CSS class names in HTML if you want, it provides CSS class name completion for the HTML class attribute based on the definitions found in your workspace or external files referenced through the link element. And gives you autocompletion for CSS class definitions that can be found in your workspace (defined in CSS files or the in the file types listed in the Supported Language Modes section)

    0 讨论(0)
  • 2021-02-05 03:31

    Downgrading the 'HTML CSS Support' extention to v1.3.3 will fix the problem.

    0 讨论(0)
  • 2021-02-05 03:33

    Check if extension "HTML CSS Support" got auto-updated. If it did, then it will ask for reloading of VS Code. Do it. Had exactly same issue today.

    Update

    That did not help.

    Looks like the issue should have been solved with the next release of the extension, but still, some of the Problems are there. Check the github: https://github.com/ecmel/vscode-html-css/issues

    In short, what you need to do is go to VS Code settings and switch from "User" to "Workspace". Then type "css settings" in settings search bar and open the exact same option under "Extensions". Click "CSS: Style Sheets", which will open settings.json for workspace and add your CSS files paths there. Hopefully it will solve all the Problems for you.

    0 讨论(0)
  • 2021-02-05 03:34

    If you are using newer version of HTML CSS Support (>= 1.5.0), you can add the following css.validation settings to your settings.json which should clear this issue. Don't forget to reload VS Code after changing the settings though.

    0 讨论(0)
提交回复
热议问题