2014-09-03 98 views
0

我测试我的网站在不同的屏幕和设备上,除了Ipads以外,所有的工作都很好。媒体查询不起作用,因为它应该

媒体查询是这样的:

/* Smartphones (portrait and landscape) ----------- */ 
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) { 
    .container { 
     width: 250px; 
    } 
} 
/* Smartphones (landscape) ----------- */ 

@media only screen and (min-width: 321px) { 
    .container { 
     width: 250px; 
    } 
} 
/* Smartphones (portrait) ----------- */ 

@media only screen and (max-width: 320px) { 
    .container { 
     width: 250px; 
    } 
} 
/* iPads (portrait and landscape) ----------- */ 

@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) { 
    .container { 
     width: 700px; 
    } 
} 
/* iPads (landscape) ----------- */ 

@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) { 
    .container { 
     width: 700px; 
    } 
} 
/* iPads (portrait) ----------- */ 

@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: portrait) { 
    .container { 
     width: 700px; 
    } 
} 

当我测试了在iPad上,而不是700像素,容器是250像素(智能手机景观媒体查询)。我已经在很多网站上测试过它们,并且它们都没有给我正确的容器值(700px)。

但是,我拥有一台小型计算机(东芝笔记本电脑更具体),我在那里测试了网站,当它应该是250像素时,容器是700px!

谁能告诉我发生了什么事?

+0

尝试给身体一个背景颜色,并检查媒体查询是否正常工作... – Siyah 2014-09-03 10:51:50

+0

你是什么意思? – user3982778 2014-09-03 10:54:31

回答

0

我认为这个问题是在这里:

/* Smartphones (landscape) ----------- */ 

@media only screen and (min-width: 321px) { 
    .container { 
     width: 250px; 
    } 

} /*智能手机(纵向)----------- */

你没有在这里上条件,即最大宽度:500px和浏览器混合iPad的媒体查询和媒体查询。

+0

我正在使用此示例http://responsivedesign.is/develop/browser-feature-support/media-queries-for-common-device-breakpoints – user3982778 2014-09-03 11:21:02

+0

尝试给出较高的条件。 – Matzach 2014-09-03 11:30:30