It just takes practice. It's something you can develop as a skill! What really helps me is to keep some simple ideas in mind. Some things that might pertain to you in particular could be like this.
"It's fine to be sad." This one is important! It's fine. If someone looks down on you for being sad when you're hurt, then they're the one in the wrong, not you. There are no bad reasons for your feelings, only for taking them out on others.
"Everyone has reasons." Anyone who's being mean to you, on purpose or unintentionally, has something going through their head. And frequently, they don't actually have bad intentions. Sometimes you can't figure out what's wrong, but if you try to keep this in mind, things seem a little better.
"If you have good intentions, it's not your fault." Sometimes people are mean, even you. But when you're not being mean on purpose, then problems that come up aren't really your fault. You tried your best! When you stop thinking "What did I do wrong?" and blaming yourself, you can calm down and try to figure out the real reason. Humiliation is good, accepting your own mistakes is good, but self-blame feels awful and it spirals out of control.
"You can fix it." If there's a problem, you can fix it! This is simple, but people forget. Sadness doesn't last forever, your friends won't be mad forever, and you can work to make up a bad grade. Anytime you have a problem, just remember that there's never nothing you can do about it, even if the something is just to take a break and cool off.
Even if you're sad, it's important to keep trying.
Also! Something more specific that I really like is visiting kidshealth.org. Just stay in the kid section. There are a lot of articles on feelings and other things. They're oriented toward kids, so it might feel a little like you're being talked down to, but I think such a simplistic style is really calming when you're down. There are other places like this on the Internet, but no matter how many searches I complete, I always come back to this one. These three are really good.
Another specific thing is talking to others who are feeling bad. Saying nice things to others makes you feel good, it makes them feel good, and it's a lot easier to solve a problem when you're solving it for someone else instead of for yourself.
Most of all, remember to stay positive!