iphone - CSS 媒体查询 - 无法使其正常工作

标签 iphone css media-queries

我有以下 CSS,包括针对 iphone 用户的媒体查询,但似乎不起作用:

body
{
background: url('background.png') no-repeat center center fixed;
background-size:100%;
}

#tab
{
width:30%;
height:60%;
position:fixed;
background: url('tab.png') no-repeat center center fixed;
background-size:33%;
top:20%;
left:35%;
opacity:0.7;
}

@media only screen and (max-device-width: 480px) 
{
body
{
background:#1589FF;
}

#tab
{
width:30%;
height:60%;
position:fixed;
background: url('tab.png') no-repeat center center fixed;
background-size:33%;
top:20%;
left:35%;
}
}

正常的 CSS 工作正常,但当切换到 iphone 时设计不会改变。谁能建议为什么上面的媒体查询似乎不起作用?我错过了什么吗?

最佳答案

改为:

@media only screen and (max-device-width: 480px) 

尝试:

@media (max-width: 480px)

OR

 @media only screen and (max-width: 480px) 

关于iphone - CSS 媒体查询 - 无法使其正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18444692/

相关文章:

ios - 如何对 NSMutableURLRequest 发出第二个请求?

css - 本地字体因 Chrome 和 FireFox 更新而中断

css - 将 div 放在容器中内容的底部

twitter-bootstrap - 移动问题,修改 Bootstrap 类或错误的媒体查询

android - 尝试使用媒体查询定位 Moto G 和三星 Galaxy S4

ios - 为什么我在 Xcode 6 中收到错误 "Failed to locate or generate matching signing assets"?

iphone - Xcode 不会释放资源文件

css - float div 之间的间隙

css - 背景颜色不随媒体查询拉伸(stretch)

iphone - UIView animateWithDuration 仅动画一次