2012-12-12 75 views
1

我试图用我的媒体查询锁定iphone 5,并且横向背景没有显示出来。由于我没有任何特殊的视网膜显示图形,我想知道是否可以使用与媒体查询相同的图形。我如何定位iPhone 5横向导向?iphone 5的媒体查询

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

    #homepage{ 
    background: url('images/480x320_Horizontal.jpg') no-repeat fixed #00314d; 
    } 
} 

回答

2

使用meta标签,迫使iPhone渲染视作为设备宽度..

<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"> 

而现在使用媒体查询,用于设置横向模式的风格,为iPhone是> 320像素;

@media screen and (min-width: 321px){ 
    /*Style goes here*/ 
} 
+0

我已经有元名称代码。由于某些原因,iPhone 5不显示背景图片,它可以正常工作,直到iphone 4s – hershey

+0

@hershey这篇文章可能会帮助你http://halgatewood.com/iphone-5-media-query/ –

+0

这也将捕获所有其他类型符合此范围的移动设备。你是否想要成为iOS?如果是这样,请使用'only screen and(device-width:320px)' – roberthuttinger