Answer the question
In order to leave comments, you need to log in
How can media queries be specified without an id or class?
Look, I was told that now it is best to practice writing code without classes, so I did. I specified
each element in the CSS through parent blocks. Example: https://jsfiddle.net/bx33cL1n/
But with this method I can't make media queries because I get an error. What to do? I don’t want to prescribe classes and remake the site ..
Answer the question
In order to leave comments, you need to log in
Отвечу не совсем на вопрос. Не слушай того человека, который тебе это сказал. Это крайне сомнительный способ что-либо делать и по сути не правильный, да и к тому же бессмысленный, не забивай голову такой фигней, если только начинаешь верстать.
Hmm... what do you plan to do if you need to add some new element somewhere inside the existing ones? Will you rewrite styles? Because in this case, your tag hierarchy chain, written in styles, will go to hell)
In general, now BEM rules, I advise you to get acquainted :)
In BEM, just everything is on classes, and thus we avoid nesting.
The second point, you say that you are writing a media query and an error occurs, they do not work!? Most likely, you use one selector in the main styles, and another, with a lower weight, in the media query. Here, about specificity.
For example, if you write in styles:
div.class-some .wrapper h2 span{
color: red;
}
@media screen and (min-width: 1200px ){
.class-some span{
color: green;
}
}
@media screen and (min-width: 1200px ){
div.class-some .wrapper h2 span{
color: green;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question