移动端2倍图和3倍图的处理方法

/* 如果设备像素大于等于2,则用2倍图 */
@media screen and (-webkit-min-device-pixel-ratio: 2), screen and (min--moz-device-pixel-ratio: 2) {
  .img {
    background-image: url(../images/[email protected]);
    background-size: 30px 30px;
    width: 30px;
    height: 30px;
    background-repeat: no-repeat;
  }
}
/* 如果设备像素大于等于3,则用3倍图 */
@media screen and (-webkit-min-device-pixel-ratio: 3), screen and (min--moz-device-pixel-ratio: 3) {
  .img {
    background-image: url(../images/[email protected]);
    background-size: 30px 30px;
    width: 30px;
    height: 30px;
    background-repeat: no-repeat;
  }
}

猜你喜欢

转载自www.cnblogs.com/edczjw-Edison/p/12522682.html