Is this fine - in general or for discoverability's sake?
In cases where there is no interoperability/interchangeable code, this is definitely not OK, and such answers should be downvoted and deleted, for the same reason that it's not OK for fifteen answers that all give the same exact solution: this content is not useful.
If you are looking for how to Foo a Bar in, say, the Klingon programming language, and someone posts an answer on how to Foo a Bar when using the Esperanto programming language, that's not helpful or useful to you, nor is it likely to be useful to people trying to do it in Esperanto... because they won't be looking for their solution in a question about doing something in the Klingon language.
The linked answers address a slightly different scenario, i.e. interchangeable technologies (JavaScript vs. CSS)
To speak to your specific example, I even strongly dislike and discourage this with things that are quite interoperable like CSS and JavaScript. While JS can apply CSS styles, my recommendation is always "don't provide a JS answer" unless the OP explicitly mentions they're willing to use non-CSS solutions, or if the thing literally cannot be done at all in CSS (but can in JS), but preferably only after explaining that/why it can't be done in CSS.
In another scenario, I would feel frustrated if I asked how to do something in ASP.NET with WebForms and someone gave an answer along the lines of - "here's how you do this in MVC".
Or actually not-an-answer?
Do not, however, flag such a thing as "Not An Answer"; it will get declined due to the gymnastic interpretation of that flag by moderators and users. The current consensus (if you can call it that) is that, despite the verbiage of the NAA flag's description, something is only validly NAA if it could not possibly be an answer to any question on the site.
tsql
question with something like: "For anyone who lands here when looking for how to do this in Google Big Query, see this question for the proper syntax." But I feel like there's already a Meta question about this with better guidance, I just can't find it.