使用媒体查询的 min-device-width 替代 min-width 属性,它将检测的是设备宽度而不是浏览器宽度。浏览器大小重置时,图片大小不会改变

2017-07-05 11:51:00
admin
原创
511
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8"> 
<title></title> 
<style>
/* For device width smaller than 400px: */
body {
    background-repeat: no-repeat;
    background-image: url('http://www.ybao.org/data/upload/201707/f_c3d631c32fe975764e8b9cfc31d15b60.jpg'); 
}

/* For device width 400px and larger: */
@media only screen and (min-device-width: 400px) {
    body { 
       background-image: url('http://www.ybao.org/data/upload/201707/f_9fa4b15f454aebc6a635aeb9ba955c7a.jpg'); 
    }
}
</style>
</head>
<body>

</body>
</html>
  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络