The @media
is used for responsive html css design.
using the @media screen and (min-width: 30em)
it indicates that if the screen size is 30em or larger then that specific css properties will be applied.See the small example for better understanding.
The em is used for dynamic font size.If you use px
for font size then font will not resize when you change your system font-size.
Other hand em
or rem
is dynamically changed in size when you change your system font size.
.example{
background-color:red;
padding:100px;
}
@media only screen and (max-width: 700px){
.example{
background-color:yellow;
}
}
<html>
<head>
<style>
</style>
</head>
<body>
<div class="example">
<p>when screen size is 700px or lesser then background will be yellow otherwise red</p>
</div>
</body>
</html>