# Centering Elements with Flexbox
The biggest CSS headache is "How do I vertically center something". Throw away your migraine pills, it's now been solved with Flexbox!
.parent {
display: flex;
align-items: center;
justify-content: center;
}
Keeping this code note super short. Because I'll be spending the entire next month posting about Flexbox on my Twitter and Instagram Account!
The series is called #Flexbox30. You will learn flexbox in 30 days with 30 code tidbits. You heard that right, a new code tidbit every day for 30 days 💪 It starts September 1st 🔥
If you're interested in this FREE series, make sure you follow me on:
- Instgram > @samanthaming
- Twitter > @samantha_ming
# Flexbox with Auto Margins
You can also achieve the same outcome by using auto margin!
.parent {
display: flex;
}
.child {
margin: auto;
}
This is new for me. If you're interested to learn more about this. Here are some great resources: