Visual Studio Code - Empty CSS ruleset

Asked

Viewed 435 times

1

When I create a class in HTML and go to CSS and put ". alguma_Class{}" the css file does not recognize this class in the automatic search and only works if I type everything in hand and only after that it starts to appear in the automatic search and without speaking when I type the class appears the error that you have in the print. It wasn’t like that, it was like that out of nowhere. Someone can say why?

Error

erro

1 answer

1


About in the file . CSS you can not auto complete a class that only exites in HTML this is documented here: https://github.com/Microsoft/vscode/issues/28442

I think you must have got confused, because as you can see in GitHub of the project that Feature has not yet been developed...


Your problem with the "erro" is that you are not putting any property within the class. In short, you have a class .some-class { vazia } that has no property within the alerta.

Example of the same error in the console in the tab Problems of VS Code

inserir a descrição da imagem aqui

In VS Code, you can disable this type of alert by going to Settings and setting preferences for CSS files as shown below.

Gets into Settings, in the search bar look for "empt" find inside Extensions the topic CSS and puts Ignore

inserir a descrição da imagem aqui

See that after adjusting to Ignore error no longer appears in tab Problems or in the CSS file

inserir a descrição da imagem aqui

  • Ball show bro... Obg... but that was half the problem, the other is the autocomplete... If you put a class in any element in html and then go to it in CSS and place ". classquevcquer", autocomplete does not find that class... but... if you put it all writing at least once, the next time q vc will write this class in the CSS document, then the autocomplete already recognizes... tendeu?

  • 1

    As far as I know this is the normal behavior of VS Code, not hare of in CSS he recognize a class that only exists in HTML and make the autocomplet... never noticed this behavior in the file . css autocomplete a class that is only in HTML...

  • 1

    What I know is that Intellisense for example in HTML completes the classes that are already discrete in .CSS... You can look here https://stackoverflow.com/questions/45865053/vs-code-detect-css-classes-and-ids-from-html-and-autocomplete and see that there are some extensions that can help you. See the Edite I made right at the beginning of my reply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.