您可以考虑设备宽度和设备像素比。所以我们可以解决这个问题。
/* Large Monitors devices (large desktops, 1920px and up)*/
@media only screen and (max-width: 1920px) {
.logo {
width: 160px;
height: 109px;
background-image: url("/img/1920px/logo/logo-1x.png");
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and ( min--moz-device-pixel-ratio: 2),
only screen and ( -o-min-device-pixel-ratio: 2/1),
only screen and ( min-device-pixel-ratio: 2),
only screen and ( min-resolution: 192dpi),
only screen and ( min-resolution: 2dppx) {
.logo {
width: 160px;
height: 109px;
background-image: url("/img/1920px/logo/logo-2x.png");
}
}
}
/* Extra large devic
es (large desktops, 1280px and up)*/
@media only screen and (max-width: 1280px) {
.logo {
width: 120px;
height: 82px;
background-image: url("/img/1280px/logo/logo-1x.png");
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and ( min--moz-device-pixel-ratio: 2),
only screen and ( -o-min-device-pixel-ratio: 2/1),
only screen and ( min-device-pixel-ratio: 2),
only screen and ( min-resolution: 192dpi),
only screen and ( min-resolution: 2dppx) {
.logo{
width: 160px;
height: 109px;
background-image: url("/img/1280px/logo/logo-2x.png");
}
}
}
/* Large devices (desktops, 960px and up)*/
@media only screen and (max-width: 960px) {
.logo{
width: 100px;
height: 68px;
background-image: url("/img/960px/logo/logo-1x.png");
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and ( min--moz-device-pixel-ratio: 2),
only screen and ( -o-min-device-pixel-ratio: 2/1),
only screen and ( min-device-pixel-ratio: 2),
only screen and ( min-resolution: 192dpi),
only screen and ( min-resolution: 2dppx) {
.logo{
width: 160px;
height: 109px;
background-image: url("/img/960px/logo/logo-2x.png");
}
}
}
/* Medium devices (tablets, 640px and up)*/
@media only screen and (max-width: 640px) {
.logo{
width: 78px;
height: 42px;
background-image: url("/img/640px/logo/logo-1x.png");
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and ( min--moz-device-pixel-ratio: 2),
only screen and ( -o-min-device-pixel-ratio: 2/1),
only screen and ( min-device-pixel-ratio: 2),
only screen and ( min-resolution: 192dpi),
only screen and ( min-resolution: 2dppx) {
.logo{
width: 160px;
height: 109px;
background-image: url("/img/640px/logo/logo-2x.png");
}
}
}
/* Small devices (landscape phones, 320px and up)*/
@media only screen and (max-width: 320px) {
.logo{
width: 78px;
height: 42px;
background-image: url("/img/320px/logo/logo-1x.png");
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and ( min--moz-device-pixel-ratio: 2),
only screen and ( -o-min-device-pixel-ratio: 2/1),
only screen and ( min-device-pixel-ratio: 2),
only screen and ( min-resolution: 192dpi),
only screen and ( min-resolution: 2dppx) {
.logo{
width: 160px;
height: 109px;
background-image: url("/img/320px/logo/logo-2x.png");
}
}
}