Is it possible in CSS3 to create a selector like this?
#id(min-height: 300px) {
...
}
If yes, how can I do it?
Is it possible in CSS3 to create a selector like this?
#id(min-height: 300px) {
...
}
If yes, how can I do it?
If you want to specify the height based on the screen, you could use a media query.
@media (min-height: 300px) { ... }
However, it sounds like you are actually wanting to find all elements with a given size. Unfortunately, there isn't a CSS selector for that. If you want to do that, you'll have to use JavaScript and iterate over all of the possible elements.
Ideally, you'd want to narrow down your set of elements (like by class or common parent):
document.querySelectorAll('#parent *')
document.querySelectorAll('.someClass')
However, if you just want to loop over everything, you can use:
document.querySelectorAll('*')
Regardless of which on you pick, you can use filter()
to filter for only the ones with the specified height you want:
const elements = Array.prototype
.filter.call(document.querySelectorAll('*'), el => el.offsetHeight >= 300);
From there, you can do whatever you want with them.
Note that it's ideally important to reduce your sets by choosing a selector more narrow than *
because the more elements it has to loop through, the slower it'll be.