【发布时间】:2015-08-21 00:13:44
【问题描述】:
我正在尝试根据不同的分辨率为我的网站设置背景图片。我还想包括视网膜媒体查询,这样如果视网膜设备访问我的网站,就会加载正确的图像。问题是我总是得到最高分辨率,当然不是视网膜......这是我的 css
<style>
#background
{
font-size: large;
position: relative;
top:50%;
left:50%;
color: white;
}
@media only screen and (min-device-width : 768px) and (max-device-width:1024px) and (orientation : landscape)and (-webkit-min-device-pixel-ratio: 2)
{
#demo{
width: 100%;
min-height: 800px;
background-size: 100%;
background-repeat: no-repeat;
position:absolute;
background-image: url(demo_BG_1024@2x.png);
background-color: rgb(0,0,0);
}
}
@media screen and (min-width:1025px)
{
#demo{
width: 100%;
min-height: 800px;
background-size: 100%;
background-repeat: no-repeat;
position:absolute;
background-image: url(demo_BG_1024.png);
background-color: rgb(0,0,0);
}
}
@media screen and (max-width:1024px)
{
#demo{
width: 100%;
min-height: 800px;
background-size: 100%;
background-repeat: no-repeat;
position:absolute;
background-image: url(demo_BG_1024.png);
background-color: rgb(0,0,0);
}
}
@media screen and (max-width:720px)
{
#demo{
width: 100%;
min-height: 800px;
background-size: 100%;
background-repeat: no-repeat;
position:absolute;
background-image: url(demo_BG_720.png);
background-color: rgb(0,0,0);
}
}
@media screen and (max-width:320px)
{
#demo{
width: 100%;
height: 100%;
background-size: 100%;
background-repeat: no-repeat;
position:absolute;
background-image: url(demo_BG_320.png);
background-color: rgb(0,0,0);
}
}
</style>
【问题讨论】:
标签: html css retina-display