场景:为适应各种大小的屏幕
自适应布局我知道的两种方式
1.使用媒体查询,下面制定了几种适应方式,例如第一个表示屏幕宽度在320px-360px之间的,html字体大小适配为13.65px
<style>
@media only screen and (max-width: 360px) and (min-width: 320px){
html{
font-size:13.65px;
}
}
@media only screen and (max-width: 375px) and (min-width: 360px){
html{
font-size:23.4375px;
}
}
@media only screen and (max-width: 390px) and (min-width: 375px){
html{
font-size:23.4375px;
}
}
@media only screen and (max-width: 414px) and (min-width: 390px){
html{
font-size:17.64px;
}
}
@media only screen and (max-width: 640px) and (min-width: 414px){
html{
font-size:17.664px;
}
}
@media screen and (min-width: 640px){
html{
font-size:27.31px;
}
}
</style>
2.响应式,获取到屏幕的宽度,计算出一定的比例大小