3 ms·
Sorry for butting in on this interesting conversation but regarding media queries being code smell, I currently see no other portable way to deliver multi-resol
by Santosh83 6y ago
Sorry for butting in on this interesting conversation but regarding media queries being code smell, I currently see no other portable way to deliver multi-resolution background images. :-( Without JS libs that is...
- brundolf 6y ago"Code smell" doesn't mean "never justified", it just means "you should look at it with a skeptical eye" Your usecase sounds legitimate to me. Given that you're talking about different image files, you're fundamentally talking about discrete cases, for which media queries are appropriate. The problems come up when people take something that doesn't need to consist of discrete cases - like element sizing, or whatever - and turn it into a set of discrete cases using media queries. This makes the page fragile against unexpected new sizes, instead of interpolating cleanly. Good CSS derives as many of its values as possible by channeling the continuous inputs of content size, viewport size, etc into other continuous values like the size and positioning of individual elements. The browser already does this by default; you just have to implement your vision while preserving as much of that intrinsic property as possible :)