Back in the day (i.e. 2003, before the phenomenon called Facebook hit our computer screens), there was a thing called online forums. As a third year theatre student, I had access to one created especially for theatre students at Curtin to review plays and generally dribble on about nothing. I never created a username because a lot of the talk was smutty, slanderous and rubbish, but a friend of mine got hooked. She started to be given a hard time online by some of the guys in our course (basically because they were 'popular' and she wasn't....nothing much changes from high school sometimes). Then one of the older students, who was also the creator and moderator of the forum, went in to bat for her. The guys who had been having a go at her were doing it under the guise of humour. A lot of people thought they were hilarious....except me, my friend....and the moderator. He was most unimpressed at what he called '98% mucking around, 2% malicious intent'. It was the 2% that he was concerned about.
Have you ever had someone have a go at you, but acted like they were joking? Other people who overheard what they said may have thought it was a joke and had a good old chortle, but they didn't really get it. You got the 'dig' behind the humour. They may have been insulting you about something in your past, something just between the two of you.
So, why not just come out and insult you? Why mask it with humour? Well, it's so they can get away with looking humorous and you still get the point. If they just came out and said it, everyone would think they were a nasty pastie. It's their way of putting you in your place without damaging their reputation.
How do you stop people doing it to you? I've found the best way is (if it's done in person) to confront them. Say, "What did you mean by that?" Very rarely will they have the guts to repeat it. Bullies are cowards after all.