Answer the question
In order to leave comments, you need to log in
How to create a condition in sass with a check for the presence of the data attribute?
Is it possible to write a condition like this in sass:
if(data-name) {
.name { display:block; }
}
Answer the question
In order to leave comments, you need to log in
Your sass compiles to css and at this stage it does not see any "blocks".
It is also impossible to make such conditions in css itself.
But you can implement this behavior by hand using selectors:
.first {display: block }
.second { display: none }
[data-name] {
.first {display: none }
.second { display: block }
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question