2 ms·
"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
by 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 :)