css分辨率识别,移动端固定图片大小

来源:互联网 发布:数据分析属经济学吗 编辑:程序博客网 时间:2024/05/16 17:16

1.min-width从小到大书写,max-width从大到小书写

.img_div{

width:5rem !important;
height:7rem !important;
}
@media screen and (min-width: 340px) { 
.img_div{
width:6rem !important;
height:8.4rem !important;
}
}
@media screen and (min-width: 410px) { 
.img_div{
width:7rem !important;
height:9.8rem !important;
}
}
@media screen and (min-width: 600px) { 
.img_div{
width:11rem !important;
height:15.4rem !important;
}

}

2.min-width与max-width一起使用

@media screen and (min-width:600px) and (max-width:960px)

3.(摘抄)写法

<link rel="stylesheet" type="text/css" href="style.css" media="screen and (min-width: 600px) and (max-width: 800px)">
意思是当屏幕的宽度大于600小于800时,应用style.css文件设置样式