By using relative units like em or rem, you can achieve equal scaling for elements and create more flexible media queries.
UPDATED:
Here is an example of how to utilize em:
.parent {
background: red;
font-size: 20px;
padding: 1em;
}
.child {
margin: 1em;
font-size: 15px;
}
.childOfChild {
margin-left: 1em;
font-size: 2em;
}
<div class="parent">
<h2 class="child">
Hello World!
<span class="childOfChild">Some Text</span>
</h2>
</div>
Take a look at this example demonstrating the use of rem:
html {
font-size: 16px;
}
.child {
font-size: 1rem;
padding: 1rem;
background: blue;
color: white;
}
.childOfChild {
font-size: 0.8rem;
margin-left: 1.2rem;
}
@media (min-width: 2000px) {
html {
font-size: 20px;
}
}
@media (max-width: 1200px) {
html {
font-size: 14px;
}
}
@media (max-width: 768px) {
html {
font-size: 12px;
}
}
<div class="parent">
<h2 class="child">
Hello World!
<span class="childOfChild">Some Text</span>
</h2>
</div>