我有以下CSS:
@media screen and (orientation:portrait) {
body {
background-image: url(../img/background.jpg);
background-size: auto 100%;
}
}
@media screen and (orientation: landscape) {
body {
background-image: url(../img/background.jpg);
background-size: 100% au
我有一个应用程序,它设置为横向模式,因为它包含的内容。我想做的一件事就是给一张纸拍张照片。我展示的UIImagePickerController锁定在纵向模式,因为它适合纸张大小。在用户拍摄照片后,我将该图像作为背景加载到UIWebView上。我使用webview的原因是因为有时我也需要在那里加载一个.pdf。无论如何,我使用CSS设置背景。这是代码。
//img is the path to an image.
myHtml = [NSString stringWithFormat:
@"<html><head>"
我使用此媒体查询800px设备的目标视窗最大宽度,最小为400px
@media screen and (max-width: 800px) and (min-device-width: 400px)
{
body {background:#fff;}
}
我需要更改横向的颜色,为此我使用以下代码
@media screen and (orientation:landscape)
{
body {background:red;}
}
它在设备中工作良好,但背景红色适用于pc浏览器,如何在设备横向应用背景红色?
谢谢。
我正在写一些jQuery代码,我想要检测移动设备的方向,无论是纵向还是横向。
我已经尝试了while语句,但它们不断地向我发送测试警报,但都无济于事。
我的jQuery:
function test() {
if (window.matchMedia("(orientation: portrait)").matches) {
alert('You are in portrait!');
}
else if (window.matchMedia("(orientation: landscape)").matches) {