我想根據不同的分辨率爲我的網站設置一個背景圖像。我也想包括視網膜媒體查詢,以便如果視網膜設備訪問我的網站,正確的圖像將被加載。事情是,我總是得到這當然不是視網膜最高分辨率...這裏是我的CSSCSS視網膜和非視網膜媒體查詢
<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([email protected]);
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>
謝謝你的建議;)爲什麼Firefox不顯示現在的背景是什麼? – user3485417
只有firefox?它不應該在任何瀏覽器上工作,因爲我用1x.png而不是用於非視網膜媒體的2x.png圖像。 – Prime
現在我完全失去了能不能給我一個工作的例子?我是視網膜新手。謝謝 – user3485417