前端二倍图和三倍图的自适应调用


/* 如果设备像素大于等于2,则用2倍图 */
@media screen and (-webkit-min-device-pixel-ratio: 2), screen and (min--moz-device-pixel-ratio: 2) {
  .img {
    background-image: url(../images/arrow@2x.png);
    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/arrow@3x.png);
    background-size: 30px 30px;
    width: 30px;
    height: 30px;
    background-repeat: no-repeat;
  }
}

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM