I posted an answer to a question that was voted closed as too localized, which it very much could have been. However, I did get 2 upvotes for that answer. As I browsed SO, I noticed that my rep went down 2 points, so I looked — both the original question (which was at 0) and my answer (which was at 2) were downvoted.
I think it is a perfectly legitimate question and my answer was perfectly valid. However, the community thought that it should be closed, and that's how things work. And if you think the question is bad or inappropriate, downvoting, voting to close, and commenting are the proper means of communicating this. However, downvoting answers to questions you think are bad is inappropriate, unless the answer is bad on its own. Really, there are two distinct ratings here — one for the question and another for the answer. Even if a question is bad and should be closed, that shouldn't prevent answers from being upvoted.
So what can be done to prevent people from downvoting perfectly legitimate and good answers to even the worst questions? Can anything be done about this?
EDIT:
For the record, I don't care about the 2 rep. However, I think this is a kind of "bad behavior" that needs to be discouraged. Behaviors that need to be encouraged are: treating answers independently of their question (but in context); commenting; voting to close for proper reasons; and making sure that even the worst questions are as readable as possible and properly tagged.