A
A
Anton Khavaldzhi2020-11-06 12:31:16
css
Anton Khavaldzhi, 2020-11-06 12:31:16

How to remove space before pseudo-classes/-elements after compiling scss to css?

Good afternoon! There was a problem with the compiled css file.
Code examples:

scss:
.header{
  display:block;
  ::after{
  }
}

css:
.header {
  display:block;
}
.header ::after{}


Or you have to write pseudo-classes separately
scss:

header {
  display:block;
}
header::after{}


This is where the meaning of the preprocessor is lost.

Tobish in *.css before ::after (any other pseudo-class/-element) there is a space and as a result the code does not work.
How to fix it?
I am using Gulp 4 and Visual Studio Code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-11-06
@khavaldji

Why don't you put an ampersand before the pseudo-class? &::after, the compiler thinks that this is a nested class, so it puts a space and the ampersand lets you know what to use next with the parent class, it means 'and', that is
. header {
/*some style*/
&::after {
content '';
}
}
And so on

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question